开发者

I Can't make RewriteBase and RewriteRule to work properly

My structure is the following:

mywebsite/clubeadv/

Inside that folder I have a file ca开发者_高级运维lled 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜