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.

tffaku
  • 23
  • 4
  • Possible duplicate of [remove query string from end of url URL using .htaccess](http://stackoverflow.com/questions/14071671/remove-query-string-from-end-of-url-url-using-htaccess) – Masivuye Cokile Mar 24 '17 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. – Halcyon Mar 24 '17 at 15:20
  • @Halcyon: what do you mean by router.php? – tffaku Mar 25 '17 at 04:36

0 Answers0