Solved

Can the URL rewite module help me? (mod_rewrite)

Posted on 2003-10-29
6
259 Views
Last Modified: 2010-03-04
I have a php file will generate dynamic pages by different parameter:

http://www.mydomain.com/photos.php?category=car
http://www.mydomain.com/photos.php?category=building


I want to replace the above URLs by the followings:

http://www.mydomain.com/photos/car
http://www.mydomain.com/photos/building

(But actually, I don't have the photos/car/index.php file in the server)


Is it possible to rewrite like this?
I think it is quite diffcult, it would be great appreciated if also tell me how to do it :)

Please advise. Thanks.
0
Comment
Question by:saikit
  • 3
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
kalosi earned 125 total points
ID: 9648156
Yes, the rewrite engine is meant exactly for this

here is the rule

RewriteEngine on
RewriteRule ^/photos.php?category=(.*)$ /photos/$1

david
0
 
LVL 1

Expert Comment

by:st
ID: 9649028
Thanks, David.

I put the two line in the http.conf file (within the <VirualHost *> tag)

Then, restart the Apache server and no error.

However, when I try the rewrite URL, it says error 404.

What should I check now?
0
 
LVL 4

Expert Comment

by:kalosi
ID: 9649042
The HTTP 404 error is document not found.

The rule is OK the problem is with it's destination.

In this links

http://www.mydomain.com/photos/car
http://www.mydomain.com/photos/building

the car and bulding are directories ??

if yes you must add an ending slash into the destination so the rule will be like this

RewriteEngine on
RewriteRule ^/photos.php?category=(.*)$ /photos/$1/

david
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 1

Expert Comment

by:st
ID: 9649093
I added the ending slash and restart apache, but still return 404 error. :(
0
 

Author Comment

by:saikit
ID: 9649488
I changed the "AllowOverride None" to "AllowOverride All", then restart apache.

After that, I add the these 2 line into the .htaccess file:

RewriteEngine On
RewriteRule ^photos/(.*) /photos.php?category=$1


Now, it is working.  But, because I using <VirtualHost> for several sites, what is the security implication for chageing to "AllOverride All" that I should consider?

Thanks.
0
 
LVL 4

Expert Comment

by:kalosi
ID: 9649806
It only defines what can you override for example in .htaccess files.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

18 Experts available now in Live!

Get 1:1 Help Now