- Impact
- 19
hey
I am working on a website and I want to rewrite the URLS to make it more SEO friendly.
I was able to to convert anything.php to anything.html easily but i have a GET form on the website that returns the query like
site.com/view.php?site=WWW.SOMEWEBSITE.COM
I want it to rewrite it to something like "site.com/view/somewebsite.com"
I am using the following code, but it gives me a "Redirect LOOP" error
I am not sure if this can be done here but I also want it to error handle and strip anything before the "www." aswell
for example if the user types in "http://www.somesite.com" i want the url to be rewritten as "site.com/view/somesite.com" and if someone types in "www.somesite.com" the url will be written the same and finally..if someone types "somesite.com" the url will be rewritten the same
Also what would the PhP code look like for that? because after the url has been rewritten, i want to grab the site and do something with it..and i only want to get stuff after the "http://www." or "www."
thanks
I am working on a website and I want to rewrite the URLS to make it more SEO friendly.
I was able to to convert anything.php to anything.html easily but i have a GET form on the website that returns the query like
site.com/view.php?site=WWW.SOMEWEBSITE.COM
I want it to rewrite it to something like "site.com/view/somewebsite.com"
I am using the following code, but it gives me a "Redirect LOOP" error
I am not sure if this can be done here but I also want it to error handle and strip anything before the "www." aswell
for example if the user types in "http://www.somesite.com" i want the url to be rewritten as "site.com/view/somesite.com" and if someone types in "www.somesite.com" the url will be written the same and finally..if someone types "somesite.com" the url will be rewritten the same
Also what would the PhP code look like for that? because after the url has been rewritten, i want to grab the site and do something with it..and i only want to get stuff after the "http://www." or "www."
thanks
Code:
RewriteEngine On
RewriteRule ([a-zA-z]+)\.html$ $1.php
RewriteCond %{REQUEST_URI} /view.php$
RewriteCond %{QUERY_STRING} ^site=([A-Za-z0-9\+]+)$
RewriteRule ^(.*)$ /s-%1? [R=301,L]
RewriteRule ^s-(.*)$ /view.php?site=$1 [L]





