You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Charles Michener <mi...@yahoo.com> on 2007/03/20 22:00:42 UTC
[users@httpd] A newbie question about mod_rewrite configuration
Hi - I'm trying to create a mod_rewrite solution to the following problem:
I want to enter http://www.myvirtualdomain.com/1234abc.htm
and have mod_rewrite translate that URL to http://www.myvirtualdomain.com/index.php?SKU=1234abc
Also, I want the solution to reside within my main Apache 2.24 configuration file (rather than using .htaccess)
After reading many suggestions here and ..., this is what I've done so far (with the results of 404 error - URL \1234abc not found)
LoadModule rewrite_module modules/mod_rewrite.so
[note: phpinfo says the module is 'present' and if I enter the URL ...?SKU=1234abc, it works]
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>
<Directory "C:/Apache/www-new">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php index.php3 index.phtml
</IfModule>
RewriteLog logs/rewrite.log Note: never hits rewrite.log
RewriteLogLevel 9
RewriteEngine ON
# RewriteRule ^//([A-Za-z0-9-]+)/.htm$ Index.php?SKU=$1
# RewriteRule ^(.*)\.htm$ index.php?SKU=$1
RewriteRule ^([^/]+).htm$ index.php?SKU=$1 [R]
#
# Virtual Hosts
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot www-new/MyVirtualDomain
ServerName MyVirtualDomain.com
ServerAlias www.MyVirtualDomain.com
</VirtualHost>
Help/suggestions are appreciated!!!
---------------------------------
Get your own web address.
Have a HUGE year through Yahoo! Small Business.
Re: [users@httpd] A newbie question about mod_rewrite configuration
Posted by Joshua Slive <jo...@slive.ca>.
On 3/20/07, Charles Michener <mi...@yahoo.com> wrote:
> RewriteRule ^([^/]+).htm$ index.php?SKU=$1 [R]
Inside httpd.conf, rewriterules are / based, so you need
RewriteRule ^/([^/]+)..... /index.php....
Also, you'll need to either use RewriteOptions Inherit inside the
<VirtualHost>, or explicitly put the RewriteRule inside the
<VirtualHost> section.
In addition, I doubt you want the [R] which will cause client's
URL-bar to change.
Joshua.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] A newbie question about mod_rewrite configuration
Posted by Serge Dubrouski <se...@gmail.com>.
On 3/20/07, Charles Michener <mi...@yahoo.com> wrote:
> Hi - I'm trying to create a mod_rewrite solution to the following problem:
>
> I want to enter http://www.myvirtualdomain.com/1234abc.htm
> and have mod_rewrite translate that URL to
> http://www.myvirtualdomain.com/index.php?SKU=1234abc
>
> Also, I want the solution to reside within my main Apache 2.24
> configuration file (rather than using .htaccess)
>
> After reading many suggestions here and ..., this is what I've done so far
> (with the results of 404 error - URL \1234abc not found)
What URL did you actually tried 1234abc or 1234abc.htm? It complains
on 1234abc which does not exist.
>
>
> LoadModule rewrite_module modules/mod_rewrite.so
>
> [note: phpinfo says the module is 'present' and if I enter the URL
> ...?SKU=1234abc, it works]
>
> <Directory />
> Options FollowSymLinks
> AllowOverride None
> Order deny,allow
> Deny from all
> Satisfy all
> </Directory>
>
> <Directory "C:/Apache/www-new">
> Options Indexes FollowSymLinks
> AllowOverride All
> Order allow,deny
> Allow from all
> </Directory>
>
> <IfModule dir_module>
> DirectoryIndex index.html index.php index.php3 index.phtml
> </IfModule>
>
> RewriteLog logs/rewrite.log Note: never hits rewrite.log
> RewriteLogLevel 9
>
> RewriteEngine ON
> # RewriteRule ^//([A-Za-z0-9-]+)/.htm$ Index.php?SKU=$1
> # RewriteRule ^(.*)\.htm$ index.php?SKU=$1
> RewriteRule ^([^/]+).htm$ index.php?SKU=$1 [R]
Per mod_rewrite documentation thist isnt supported and has to be:
RewriteRule ^([^/]+).htm$ /index.php?SKU=$1 [R]
>
> #
> # Virtual Hosts
>
> NameVirtualHost *:80
>
> <VirtualHost *:80>
> DocumentRoot www-new/MyVirtualDomain
> ServerName MyVirtualDomain.com
> ServerAlias www.MyVirtualDomain.com
> </VirtualHost>
>
>
>
> Help/suggestions are appreciated!!!
>
> ________________________________
> Get your own web address.
> Have a HUGE year through Yahoo! Small Business.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org