1

I have searched the internet and followed the steps but I can't get this to work properly.

Step1: Activated 'rewrite_module' in the apache menu. After running phpinfo(), it shows that the module is infact loaded.

Step 2: I made changes to httpd.conf:

<Directory "c:/program Files/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

Here is my .htaccess:

RewriteEngine On
RewriteRule ^tempor\.com/([^/]*)\.htm$ /tempor.com/index.php?page=$1 [L]

Goal: Rewrite url from localhost/tempor.com/index.php?page=about to localhost/tempor.com/about.htm

Test result: Nothing happens. The url isn't changed. If I put some trash texts into the .htaccess, i get an error so I know that .htaccess is being loaded.

4

1 回答 1

1

DOCUMENT_ROOT/tempor.com/.htaccess将您的代码更改为:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /tempor.com/

# external redirection from /tempor.com/index.php?page=about to /tempor.com/about.htm
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+tempor\.com/index\.php\?page=([^&\s]+) [NC]
RewriteRule ^ %1.htm? [R=301,L]

# internal forward from /tempor.com/about.htm to /tempor.com/index.php?page=about
RewriteRule ^(.+?)\.html?$ index.php?page=$1 [L,QSA,NC]
于 2013-09-10T13:05:53.543 回答