Solved

Can the URL rewite module help me? (mod_rewrite)

Posted on 2003-10-29
6
282 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DNS Question 7 69
Re-negotiation handshake failed: Not accepted by client!? 8 751
Apache 2.2 on Windows 2008 32 83
whm high memory usage in processes 7 103
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
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…
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…

809 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