简体   繁体   中英

How can I change structure of my site url?

Web sites that designed with a framework, there isnt "/" at end of their address How Can I create like these sites only with php and hide ".php" from end of my addresses?

example: www.mydomain.com/page/1 -> this means that the user should see the page 1 but in my server root there isnt any folder with name "page"

sorry for my bad english:(

What you need, is called mod_rewrite .

Here's a sample tutorial that can be useful to you : http://www.workingwith.me.uk/articles/scripting/mod_rewrite

One way to do it, is using URL rewrite support of Apache. For example, if you've a webpage called show.php?id= numeric-id you can map it to /show/ numeric-id with the following rule:

RewriteEngine on
RewriteRule ^/show/([0-9]+)$ /show.php?id=$1

This configuration can be put in Apache Virtualhost configuration or in a .htaccess file, provided that the permissions FileInfo and Options of AllowOverride are activated. To activate them, add a line like this in Apache configuration:

AllowOverride FileInfo Options

Alternatively, All activates all permissions:

AllowOverride All

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