Link to home
Start Free TrialLog in
Avatar of ApOG
ApOG

asked on

RewriteEngine issue.

I am trying to use the rewrite engine to create seo urls for our blog (custom made).

To read a post, the url looks like this:

http://www.domain.com/blog_read.php?id=[post number]

So I added the following to my .htaccess:

RewriteEngine On
RewriteRule ^blog/([0-9]+)/(.*?).html$ /blog_read.php?id=$1

So the final url looks like this: www.domain.com/blog/[post number]/the-post-title.html

But every time I test it I get a 404 page not found error.

Can anyone help?

Thanks!
Avatar of dsmile
dsmile
Flag of Viet Nam image

Does http://www.domain.com/blog_read.php?id=[post number] give you normal page or 404?

If you can access that url normally, then try this simple code

RewriteEngine On
RewriteRule ^blog/1.html$ /blog_read.php?id=1

And check whether http://www.domain.com/blog/1.html gives you http://www.domain.com/blog_read.php?id=1

If not, then may be
1. your apache server doesn't support mod_rewrite --> enable it first, or
2. your apache config doesn't allow override of apache default config using .htaccess --> change AllowOverride of your <Directory> from None to All
ASKER CERTIFIED SOLUTION
Avatar of ApOG
ApOG

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you have mod_rewrite works somewhere on your server, then try (2) in my first comment.
Avatar of ApOG
ApOG

ASKER

I'm sorry, how do I do that?
Edit this setting in httpd.conf of Apache on your server.

You can read more here http://httpd.apache.org/docs/2.0/mod/core.html
Avatar of ApOG

ASKER

Thank you for all your help!