jdMorgan

msg:1500758 | 1:06 am on Jan 8, 2003 (gmt 0) |
dawlish, This Introduction to mod_rewrite [webmasterworld.com] may be useful to you. However, why would you want to rewrite a long URL to a short one? Bearing in mind that the rewrite acts between the browser'r request and the server returning a file (or running a script), the more usual case is to rewrite a short URL to a long one. In this way, the user-supplied URL or on-page spiderable link is short, and is rewritten on request for use in accessing your page or script. You can do it either way, just trying to clarify the goal here. HTH, Jim
|
amznVibe

msg:1500759 | 1:28 am on Jan 8, 2003 (gmt 0) |
You are probably trying to make a virtual page look like a physical page? But wouldn't this cause some problems if the user bookmarks that final url? Or is this for like a search engine that finds a page listing in a database and then you want to return the real page directly without a click? I'd like to do something similar when people come into a site without the framed menu, and then I route them into the menu with the current page (leaves a messy URL). I guess I will have to pick up the mod_rewrite manual myself. -aV-
|
Robert Charlton

msg:1500760 | 7:20 am on Jan 8, 2003 (gmt 0) |
Here are two threads that I've bookmarked: How to get rid of? in URL Eliminating allergic symbols [webmasterworld.com...] CGI urls without "?"s, but also with no extensions How do search engines see these? [webmasterworld.com...]
|
jeremagne

msg:1500761 | 3:04 pm on Jan 8, 2003 (gmt 0) |
With mod_rewrite you can do this by placing the following in an .htaccess or the httpd.conf file: # To make it so that users can type in 319016.htm and the # server returns script.pl?action=form&fid=319016 you can # do this: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule "^/([0-9]+)\.htm$" [domain.com...] [P] </IfModule> # Which basically says to remember the ID number (in $1) # and retrieve the other URL instead. The [P] at the end # says to do this all in proxy mode; without it Apache # would redirect the browser to the other URL. # To go the other way -- users have to type in the long # version and the server retrieves the short URL (?!), you # could do this: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule "script\.pl\?.*fid=([0-9]+)" [domain.com...] [P] </IfModule> The mod_proxy module is required if you want to use this proxying feature. Otherwise the browser will get redirected to the new URL.
|
andreasfriedrich

msg:1500762 | 3:14 pm on Jan 8, 2003 (gmt 0) |
Welcome to WebmasterWorld [webmasterworld.com] jeremagne. Be sure to read Marcia`s WebmasterWorld Welcome and Guide to the Basics [webmasterworld.com] post. The [P] flag is not required to prevent the server from doing an external redirect. An external self redirect is only done when you explicitly use the [R] flag. Otherwise the server will just return the resource pointed to by the rewritten URI. [httpd.apache.org...] There is a big difference between an external redirect, an internal rewrite and a proxy request. Andreas
|
dawlish

msg:1500763 | 9:56 am on Jan 9, 2003 (gmt 0) |
Thanks for your advice. I have the following in my conf file contained within a virtual statement as I have a few sites on this server. LoadModule rewrite_module modules/mod_rewrite.so <Virtual> ServerName www..domain.com ServerAdmin webmaster@domain.com DocumentRoot /usr/local/etc/httpd/vhosts/www.domain.com/htdocs ScriptAlias /cgi-bin/ /usr/local/etc/httpd/vhosts/www.domain.com/cgi-bin/ RewriteEngine On RewriteRule "^/([0-9]+)\.htm$" [domain.com...] </VirtualHost> However when i go to www.domain.com/123.htm as an example I get a 404. I want [domain.com...] to be rewritten to [domain.com...] I don't want this to be apparent to the browser, spiders etc What am I doing wrong?
|
andreasfriedrich

msg:1500764 | 2:50 pm on Jan 9, 2003 (gmt 0) |
Check the RewriteLog file [httpd.apache.org] and your serverīs error log file. Andreas
|
dawlish

msg:1500765 | 4:07 pm on Jan 13, 2003 (gmt 0) |
Thanks for your advice. I have now checked the error messages and it appears as though the problem has to do with the cgi-bin not being in the htdocs folder. The error i get is a 404 is /usr/local/etc/httpd/vhosts/www.domain.com/htdocs/cgi-bin/ not found But the cgi-bin is at this level /usr/local/etc/httpd/vhosts/www.domain.com/cgi-bin/ I have the following in my conf file contained within a virtual statement as I have a few sites on this server. LoadModule rewrite_module modules/mod_rewrite.so <Virtual> ServerName www..domain.com ServerAdmin webmaster@domain.com DocumentRoot /usr/local/etc/httpd/vhosts/www.domain.com/htdocs ScriptAlias /cgi-bin/ /usr/local/etc/httpd/vhosts/www.domain.com/cgi-bin/ RewriteEngine On RewriteRule "^/([0-9]+)\.htm$" [domain.com...] </VirtualHost> Can anyone see what I'm doing wrong?
|
|