简体   繁体   中英

.htaccess friendly urls

I got a problem with my .htaccess I want to create a friendly url, I tried many ways esp. some of the ways are found on this site, but still it isn't working..

Heres my code:

    Options +FollowSymLinks +SymLinksIfOwnerMatch -Indexes  
    Header unset ETag
    FileETag None

    RewriteEngine On
    RewriteBase /
    RewriteOptions Inherit
    RewriteRule .* index.php 

    #friendly urls
    RewriteRule ^styles/style.css$ /view/style.php
    RewriteRule ^styles/style.css$ view/style.php

Without knowing exactly how it's not working for you I can see a big issue.

 RewriteRule .* index.php 

That rule matches anything . So by the time you get down to your 'friendly urls' section, the url has changed to 'index.php' which of course doesn't match.

Move the catch-all line below your 'friendly urls' section and add [L] to each of your friendly url rewrite rules.

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