3

I'm pretty new to this and was wondering how to turn my site URLs into SEO friendly URLs using .htaccess and mod_rewrite?

My URLs take the form mydomain.com/index.php?pid=1&pagename=Some Page

I would like it be mydomain.com/Some Page

OR

mydomain.com/somepage.html

I know this is possible with mod_rewrite and .htaccess, but I'm having trouble finding an exact answer on how to accomplish this?

2

You can find many tutos when you are searching over the web (or even more specifically on http://www.stackoverflow.com).

For instance, you can find this good tutorial.

Namely, you have to use conditions RewriteCond (one or more) and then add the rewriting you want to do with RewriteRule.

For instance, let say you want to redirect users to another domain (this is a dummy example, there are probably better ways to handle this):

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !^/HTML2/
RewriteRule ^(.*)$ /HTML2/$1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.