Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can the URL rewite module help me? (mod_rewrite)

Posted on 2003-10-29
6
Medium Priority
?
297 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
[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
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
kalosi earned 375 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

670 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