php - how to write conditional .htaccess file

809

My Site's every pages has Different URL with Seo variable, on page click URL becomes

index.php?seo=home
rates.php?seo=rates
reservation.php?seo=reservation

now i want to convert the URL to this

agnow.us/rates
agnow.us/information
agnow.us/reservation

Here is my .htaccess file.

Options +SymLinksIfOwnerMatch -Multiviews RewriteEngine on RewriteBase /

RewriteCond %{THE_REQUEST} \s/+rates\.php\?seo=([^\s&]+) [NC]
RewriteRule ^ /%1? [L,R=301]

RewriteRule ^/(.*)$ rates.php?seo=$1 [L,NC,QSA]
263

Answer

Solution:

You can use this code in your root .htaccess:

Options +SymLinksIfOwnerMatch -Multiviews
RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} \s/+rates\.php\?seo=([^\s&]+) [NC]
RewriteRule ^ /%1? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ rates.php?seo=$1 [L,NC,QSA]

People are also looking for solutions to the problem: php - Selecting specific rows from table

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.