Solved

Can the URL rewite module help me? (mod_rewrite)

Posted on 2003-10-29
6
293 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 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
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 
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

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

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

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…
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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

734 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