Problem: User-friendly URL on . htacess modifying the Index

Asked

Viewed 24 times

1

As I explained in the post: /questions/491299/passar-p%C3%a1gina-via-get-e-manipulating-a-url-via-htacess

I have a structure of pages: 1-Index 2-Product 3-Detail (of products) The 'Product' page is a product showcase and when you click on any of it is directed to the 'Detail', which is the product description.

I wanted to make the URL appear like this: nomedosite.com.br/product name instead of nomedosite.com.br/detail.php? product name.

I managed by touching . htacess with the following code:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?nomedosite.com.br
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteRule ^(.*)$ detalhe.php?id=$1 [L,NC]

Options -Indexes

It worked! When I click on the product it renames the URL, but now the problem is that when entering the Index of the site, IE, if type www.nomendite.com.br it sends me to the 'Detail' page (but the URL: www.nomendite.com.br) and gets no information there. What’s wrong with the code above? has how I put a page exception?

PS.: Just to be clear, the structure is as follows: www.nomendite.com.br, www.nomedosite.com.br/product, www.nomedosite.com.br/product name-1, ..., www.nomedosite.com.br/product name-n

And the pages are as follows: index php., php product. and php detail.

  • I realized that if I type a 'page' (link) that doesn’t exist for example www.nomedosite.com.br/name-any it directs to the detail.php page (with the url www.nomedosite.com.br) and doesn’t give ERROR 404!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.