0

I've tried and looked for lot of your posts, cannot get it working yet.

all URL from the site I have a simple PHP config like this example :

http://www.example.com/index.php?page=pagename

I'm wondering if I can hide Quesry_String like this :

http://www.example.com/pagename/

In the server config (apache 2.2 using virtual host without .htaccess) :

    DocumentRoot "/home/account/www/www.mysite.com/"
    Options -MultiViews
    DirectoryIndex index.php
    RewriteEngine On

    ## Rewrite 301 old Quesry_string (?p => ?page) ##
    RewriteCond %{QUERY_STRING} ^p=([^&]+) [NC]
    RewriteRule ^/$ /?page=%1 [R=301,L]

    ## Trying to hide query_string (not working) ##
    #RewriteCond %{QUERY_STRING} ^page=([^&]+) [NC]
    #RewriteRule ^/$ /%1 [R=301,L]
    #result => http://www.www.mysite.com/pagename?page=pagename (404)

    ## Rewrite 301 old page names ##
    RewriteCond %{QUERY_STRING} ^page=oldpagename$ [NC]
    RewriteRule ^/index\.php$ /?page=pagename/ [R=301,L]

    ## Remove index.php from url ##
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
    RewriteRule ^ /%1 [R=301,L]

    #Rewrite 301 index.html to root /
    RewriteRule ^/index.htm?$ index.html [NC,R=301,L]
    RewriteRule ^/index.html?$ / [NC,R=301,L]

I guess I'm almost there, thank you for your help.

jmayeux
  • 31
  • 5

1 Answers1

0

It should work for you i guess

RewriteRule ^([^/.]+)/$ index.php?page=$1 [L]

user3800108
  • 1,208
  • 1
  • 10
  • 14
  • I added it at the end while commenting : ## Remove index.php from url ## #RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?) #RewriteRule ^ /%1 [R=301,L] it does not rewrite I will try it without the other rules – jmayeux Aug 13 '14 at 10:21