I need help for rewrite url . i have site http://www. onlinedatingvenue(. )com. Please give suggestion for . htacces file url rewrite code that i can make change to dynamic url to static url seo friendly.
{answer}
One Responseto “url rewriting help (seo friendly url )?”
As requested, this is just an example—plus a bonus (any request which HOST doesn’t match exactly “www.onlinedatingvenue.com” will be redirected to “www.onlinedatingvenue.com”) avoiding duplication of content between, for instance but not limited to, http://www.onlinedatingvenue.com and http://onlinedatingvenue.com.
Note: Depending of the site config, you may need to remove the slash in rewrite rules—like “RewriteRule ^/(.*)$” becomes “RewriteRule ^(.*)$”—to make it work because the system doesn’t prefix the requested page by the root mark “/”.
Plus a good source of information to start with URL rewriting using .htaccess (see source section below).
Day,
As requested, this is just an example—plus a bonus (any request which HOST doesn’t match exactly “www.onlinedatingvenue.com” will be redirected to “www.onlinedatingvenue.com”) avoiding duplication of content between, for instance but not limited to, http://www.onlinedatingvenue.com and http://onlinedatingvenue.com.
## REWRITE DEFAULTS
RewriteEngine On
## REQUIRES http://www.onlinedatingvenue.com
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www.onlinedatingvenue.com$ [NC]
RewriteRule ^/(.*)$ http://www.onlinedatingvenue.com/$1 [L,R=301]
## STATIC 2 DYNAMIC
# Example 1:
# STATIC: /profile/joe-smith-145.html
# DYNAMIC: /profile.php?id=145
# Example 2:
# STATIC: /articles/speed-dating-for-dummies-346.html
# DYNAMIC: /articles.php?id=346
RewriteRule ^/([^/]+)/(.*-[0-9]+).html /$1.php?id=$2 [NC,L]
Note: Depending of the site config, you may need to remove the slash in rewrite rules—like “RewriteRule ^/(.*)$” becomes “RewriteRule ^(.*)$”—to make it work because the system doesn’t prefix the requested page by the root mark “/”.
Plus a good source of information to start with URL rewriting using .htaccess (see source section below).