Ben G
Ben G

Reputation: 253

SEO friendly url in PHP htaccess

I use Godaddy Apache server to build my own blog, and I did some search of SEO friendly url tutorials, and applied the following code in my web root .htaccess file to transfer links like http://www.bgmemo.com/blog.php?url=2012/08/23/4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.html to http://www.bgmemo.com/blog/2012/08/23/4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.html :

RewriteEngine on
RewriteRule ^([a-zA-Z0-9-/]+).html$ blog.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ blog.php?url=$1

But it does not work. The htaccess is working and other code in it is applied. Who can tell me what is wrong? Thanks in advance.

Upvotes: 2

Views: 1531

Answers (2)

Bruno Pinna
Bruno Pinna

Reputation: 133

This is the correctly way for don´t have problems with your .htaccess

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteRule ^blog/([a-zA-Z0-9\-/\.]+)/?$ blog.php?url=$1 [L]
</IfModule>

Upvotes: 0

ow3n
ow3n

Reputation: 6587

Try this:

RewriteEngine on
RewriteBase /
RewriteRule ^blog/([a-zA-Z0-9\-/\.]+)/?$ blog.php?url=$1 [L]

Upvotes: 4

Related Questions