1

Here, I am using following .htaccess Rewrite Rule.

Options +FollowSymLinks -MultiViews

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain1.com$ [NC] 
RewriteRule ^ http://www.domain1.com%{REQUEST_URI} [L,R=301] 

RewriteRule ^index.php$ http://www.domain1.com/ [R=301,L]

RewriteCond %{THE_REQUEST} ^GET\ /(.+)\.php [NC]
RewriteRule ^ /%1 [QSA,R=301,L]

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

</IfModule>

I need to convert:

1- domain1.com => http://www.domain1.com/
2- domain1.com/whatever.php => http://www.domain1.com/whatever
3- domain1.com/whatever.php?whatever-whatever 
=> http://www.domain1.com/whatever/whatever-whatever
4- domain1.com/whatever.php?whatever1=whatever-whatever2 
=> http://www.domain1.com/whatever/whatever1/whatever-whatever2

#1 and #2 are achieve successfully but after several trail of Rewrite Rules for #3 and #4 cannot achieve.

Rightnow, above attach .htaccess Rewrite Rules give Results:

1- http://www.domain1.com 
(Correct for non-www to www)

2- http://www.domain1.com/whatever 
(Correct for removing .php from FILENAME)

3- http://www.domain1.com/whatever?whatever-whatever 
(Wrong for not removing question mark(?) and replace with slash(/))

4- (Not Achieve)

Kindly suggest.

3
  • Possible duplicate of remove query string from end of url URL using .htaccess Commented Mar 24, 2017 at 15:18
  • This seems a little complex. You can consider rewriting all URLs to router.php which will manipulate the URL to what you want it to be. Commented Mar 24, 2017 at 15:20
  • @Halcyon: what do you mean by router.php? Commented Mar 25, 2017 at 4:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.