Jump to content

URL in php replace = with /


ChrisMartino

Recommended Posts

"http://www.example.com/index.php?page=page1&id=4&color=blue&fruit=apple" 

=> => =>

"http://www.example.com/index/page/page1/id/4/color/blue/fruit/apple"

 

im not sure if this rewrites it, but if you do write the second url, it will recognize all of the variables from the first url.

i use this for all of the sites i create. i cannot remember where it came from, but it works for what i do.

 

 

just add the below to the .htaccess file.

 

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$

RewriteRule \.(css|jpg|jpeg|gif|png|js)$ - [L]

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

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

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

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

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3&$4 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3=$4 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2=$3&$4 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3&$4&$5 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2=$3&$4=$5 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3=$4&$5 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2=$3&$4&$5 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3&$4&$5&$6 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2=$3&$4&$5&$6 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2=$3&$4=$5&$6 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3=$4&$5&$6 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3&$4=$5&$6 [L]

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&$2&$3=$4&$5=$6 [L]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.