简体   繁体   中英

I Can't make RewriteBase and RewriteRule to work properly

My structure is the following:

mywebsite/clubeadv/

Inside that folder I have a file called site.php which receives a parameter id.

So, the physical path would be:

mywebsite/clubeadv/site.php?id=something

But I want it to look like this:

mywebsite/clubeadv/site/something

(where 'something' is my parameter)

HOW DO I CONFIGURE THE .HTACCESS FILE?

I tried the following:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^site/(.*)$ site.php?id=$1

Any help would be appreciated.

Thank you.

Try removing the RewriteBase and placing the .htaccess inside your "clubeadv" folder. If your .htaccess is at the root within the "mywebsite" folder, then you could lave the RewriteBase but use RewriteRule clubeadv/site/(.*)$ clubeadv/site.php?id=$1

Either way, I'm pretty sure the "^site" causes it to look for mywebsite/site/something in your case.

It looks like you want:

RewriteEngine On
RewriteBase /clubeadv/
RewriteRule . site.php?id=%{REQUEST_URI}

That will handle URLs like www.<>.com/clubeadv/abc/edf as site.php?id=/abc/edf.

Apparently the problem was the server configuration. To enable .htaccess files, we had to:

  • Have the following module loaded:

LoadModule rewrite_module modules/mod_rewrite.so

  • Enable override for needed websites under 'directory' tag:

    AllowOverride All

Thank you to those who answered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM