Solved

Can the URL rewite module help me? (mod_rewrite)

Posted on 2003-10-29
6
287 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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