Solved

RewriteEngine issue.

Posted on 2011-09-20
6
301 Views
Last Modified: 2012-08-14
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!
0
Comment
Question by:ApOG
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:dsmile
ID: 36571703
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
0
 

Accepted Solution

by:
ApOG earned 0 total points
ID: 36571740
Nope, it does not work.

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

RewriteCond %{HTTP_HOST} ^domain.net [OR]

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

Thanks for your help dsmile!
0
 
LVL 13

Expert Comment

by:dsmile
ID: 36577954
If you have mod_rewrite works somewhere on your server, then try (2) in my first comment.
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

Author Comment

by:ApOG
ID: 36577978
I'm sorry, how do I do that?
0
 
LVL 13

Expert Comment

by:dsmile
ID: 36578406
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
0
 

Author Closing Comment

by:ApOG
ID: 36597837
Thank you for all your help!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now