ChrisMartino Posted May 19, 2010 Share Posted May 19, 2010 Well in the URL it looks much neater when you use slashes instead of equals signs so how do you replace the equals signs with slashes in PHP?. Thanks for your time, Chris. Link to comment https://forums.phpfreaks.com/topic/202315-url-in-php-replace-with/ Share on other sites More sharing options...
-Karl- Posted May 20, 2010 Share Posted May 20, 2010 rewriterule Link to comment https://forums.phpfreaks.com/topic/202315-url-in-php-replace-with/#findComment-1060901 Share on other sites More sharing options...
smarble53 Posted May 20, 2010 Share Posted May 20, 2010 "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] Link to comment https://forums.phpfreaks.com/topic/202315-url-in-php-replace-with/#findComment-1060914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.