Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RewriteEngine issue.

Posted on 2011-09-20
6
Medium Priority
?
314 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

636 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