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:[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:[post number]/the-post-title.html

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

Can anyone help?

Who is Participating?
ApOGConnect With a Mentor Author Commented:
Nope, it does not work.

I also see other rewrite rules in the htaccess (that are working):

RewriteCond %{HTTP_HOST} ^ [OR]

RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^/?$ "http\:\/\/www\.domain\.net" [R=301,L]

Thanks for your help dsmile!
Does[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 gives you

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
If you have mod_rewrite works somewhere on your server, then try (2) in my first comment.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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

You can read more here
ApOGAuthor Commented:
Thank you for all your help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.