Easyphp.htaccess rules

I need to rewrite the rules when installing easyphp on windows 7.

I need to make sure that the rules are loaded correctly, and I do not need to create many rules. also, when I copy .htaccess to my server (which is linux), I want to make sure that it works correctly.

I have no experience with this, and here is what I found on the Internet:

RewriteRule (.*) index.php?s=$1 

now, if I have a basic page, for example, "contact-us", it's fine, but if I have auxiliary pages, it’s not. how can i create subfolders?

Thank you

+7
source share
1 answer

Here is what you need to do:

 RewriteEngine On RewriteBase / RewriteRule ^([a-z0-9_\-]+)/?$ index.php?main=$1 [NC,L] RewriteRule ^([a-z0-9_\-]+)/([a-z0-9_\-]+)/?$ index.php?main=$1&sub=$2 [NC,L] 

This will allow you to have pages such as:

 http://www.domain.com/mainpage/ or http://www.domain.com/mainpage or http://www.domain.com/mainpage/subpage/ or http://www.domain.com/mainpage/subpage 

/? means slash is optional

[NC] This makes the case insensitive - the differences between "AZ" and "az" are ignored in both the extended TestString and CondPattern. This flag is only effective for comparison between TestString and CondPattern. It does not affect file system checks and subqueries.

[L] The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, further rules will not be processed.

All information about flags and rules: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

+11
source

All Articles