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.
Apache Web Server

Avatar of undefined
Last Comment
talktome_prashanth

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ravenpl

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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?
ravenpl

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
talktome_prashanth

ASKER
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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
talktome_prashanth

ASKER
Got to working... after moving to http.conf.

Thanks
ravenpl

Ah - my fault. in htaccess the leading / is stripped.
RewriteRule ^story/(.*) /story.php?id=$1 [L]
talktome_prashanth

ASKER
Looks like id is not supplied to the rewrited URL. It just showing me blank page. Any idea?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
talktome_prashanth

ASKER
Its working if I replace the rule with this
RewriteRule ^story/([0-9][0-9])/$ /story.php?id=$1 [L]