Link to home
Start Free TrialLog in
Avatar of talktome_prashanth
talktome_prashanth

asked on

mod rewrite help

Hello,
I need to rewrite some URL's using Mod ReWrite Apache Module. Below is the incoming URL

http://subdomain.Domain.com/story/41/ 

This needs to be rewrited to below url
http://subdomain.Domain.com/story.php?id=41

Anyone please help me out with .htaccess file. I need this only for subdomain. so I assume we need to place this .htaccess in subdomain directory only.


Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of talktome_prashanth
talktome_prashanth

ASKER

Looks like its not working.

I am getting the same old URL.
Any other additional steps to make sure apache takes .htaccess?
Is any RewriteRule working there? Verify the apache log.
To use RewriteEngine You need to be allowed to Override FileInfo. Refer http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
Also - You may need set RewriteBase (or change the rule) if the .htaccess is placed not in root of VirtualHost
Yeah top domain is working. I tested with wordpress permlinks.

This is info in my httpd.conf

<Directory /var/www/Domain/subdomain>
   Options FollowSymLinks
   AllowOverride All
</Directory>

<VirtualHost 65.x.x.x:80>
ServerName subdomain.domain.com
DocumentRoot /var/www/domain/subdomain
</VirtualHost>

.htaccess is placed under root folder i,e   /var/www/domain/subdomain

Error log says 302 not found. Please let me know if u need additional information.
thanks
Got to working... after moving to http.conf.

Thanks
Ah - my fault. in htaccess the leading / is stripped.
RewriteRule ^story/(.*) /story.php?id=$1 [L]
Looks like id is not supplied to the rewrited URL. It just showing me blank page. Any idea?
Its working if I replace the rule with this
RewriteRule ^story/([0-9][0-9])/$ /story.php?id=$1 [L]