简体   繁体   中英

I am getting the following error with my .htaccess file

I am getting a Internal Server Error when i use my htaccess file on a sub domain but it works fine with standard domains. I dont really understand how the htaccess file works totally so any help would be greatly aprricated.

.htaccess file

RewriteEngine on
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@-----.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

When using RewriteRules, always, always use the conditions associated with the involved module. In case the module is not available, rewrites won't work (and your website will probably be broken because it relies on rewrite rules ;-)) but you won't get a 500 error:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]
</IfModule>

If you don't get a 500 error after this, then the rewrite module is not loaded in your subdomain.

If you still get it, it's probably a redirect loop.

This is a punt - may be well off base.

Is your subdomain is based in a folder within the standard webroot? ie subdomain.server.com is rooted in a folder subdomain within the webroot folder for server.com . So the webroot is something like /httpdocs/ and the subdomain is /httpdocs/subdomain/ .

You may just need to define the RewriteBase as that folder

RewriteEngine on
RewriteBase /subdomain/
RewriteRule ^([^/\.]+)\.html index.php?act=$1 [L]

Does that help?

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