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
Solved

Using ModRewrite

Posted on 2003-10-22
8
252 Views
Last Modified: 2010-03-04
Hi,

I got this in my .htaccess file.
How do I change this to use ModRewrite

i guess like errordocs/errors/400 or some voodoo like that.
now can i use regular expressions so my list doesnt have to be this big?
thanks!

ErrorDocument 400 /errordocs/errors.php?code=400
ErrorDocument 401 /errordocs/errors.php?code=401
ErrorDocument 402 /errordocs/errors.php?code=402
ErrorDocument 403 /errordocs/errors.php?code=403
ErrorDocument 404 /errordocs/errors.php?code=404
ErrorDocument 405 /errordocs/errors.php?code=405
ErrorDocument 406 /errordocs/errors.php?code=406
ErrorDocument 407 /errordocs/errors.php?code=407
ErrorDocument 408 /errordocs/errors.php?code=408
ErrorDocument 409 /errordocs/errors.php?code=409
ErrorDocument 410 /errordocs/errors.php?code=410
ErrorDocument 411 /errordocs/errors.php?code=411
ErrorDocument 412 /errordocs/errors.php?code=412
ErrorDocument 413 /errordocs/errors.php?code=413
ErrorDocument 414 /errordocs/errors.php?code=414
ErrorDocument 415 /errordocs/errors.php?code=415
ErrorDocument 500 /errordocs/errors.php?code=500
ErrorDocument 501 /errordocs/errors.php?code=501
ErrorDocument 502 /errordocs/errors.php?code=502
ErrorDocument 503 /errordocs/errors.php?code=503
ErrorDocument 504 /errordocs/errors.php?code=504
ErrorDocument 505 /errordocs/errors.php?code=505
0
Comment
Question by:weinrj
  • 3
  • 3
8 Comments
 
LVL 16

Expert Comment

by:_nn_
ID: 9605480
Unfortunately, the documentation at http://httpd.apache.org/docs-2.0/mod/core.html#errordocument leaves no doubt : not possible. On the other side, is it really so much of a problem ?
0
 

Author Comment

by:weinrj
ID: 9607801
ah i read that documentation as well thought might be a way. i guess i will erase the query. thanks
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9608046
Just to make sure, I downloaded Apache's source code. In the set_error_document() function, I've found an explicit conversion string to integer for the 3-digit code read from the config file (or .htaccess) and a reference to a conf->response_code_strings[] table. Obviously, they didn't make it "regexp-aware", which confirms the impossibility, since it's the only place in the code where Apache deals with HTTP errors.

>> i guess i will erase the query.

I don't understand. Could you please rephrase ?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:weinrj
ID: 9608089
sorry
since there is no solution possible i should have a way to erase this question to get my points back.
0
 

Author Comment

by:weinrj
ID: 9608122
only reason i ask is this
i have gallery on my site and the mod_rewrite says this:

mod_rewrite is an Apache module that lets web server applications do clever things with URLs. Gallery uses this module to allow it to use short URLs, for example with mod_rewrite this URL takes you directly to a picture:

http://www.menalto.com/photos/Jai2/photo-aaa 
whereas without it, you'd have to use this one:

http://www.menalto.com/photos/view_photo.php?set_albumName=Jai2&id=photo-aaa 

the RedExp would been nice to make one errordocument directive, i like the URI to be shorter if possible.
0
 
LVL 16

Accepted Solution

by:
_nn_ earned 125 total points
ID: 9608293

>> since there is no solution possible i should have a way to erase this question to get my points back.

Hmm, personally, I don't mind, but you should read this :
http://www.experts-exchange.com/help/member.jsp#10 (The correct answer to some questions is "you can't do that")

>> the RedExp would been nice to make one errordocument directive, i like the URI to be shorter if possible.

Aaahh, but that's something completely different ! You don't use ErrorDocument for that. Here something that should do for your request :

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ view_photo.php?set_albumName=$1&id=$2 [QSA]
</IfModule>

I'm not so sure anymore, but also try with prepending photos/ in case it doesn't work

   RewriteRule ^photos/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ photos/view_photo.php?set_albumName=$1&id=$2 [QSA]
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.htaccess mod_rewrite: page name gets repeated multiple times 2 90
Xampp Not Stopping 9 42
CentOS 7 (Apache2) Cannot Install SSL Cert 1 72
ignore other .htaccess 2 58
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 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