可能重复:
Removing .php extension in URLs删除扩展名为.php和 “ID = XYZ?”
我已经改变了我public_html
的子目录作为主目录。 当前,mysite.com/alpha/index.php
重定向为mysite.com
。这是完美的。
同样,我有另一个文件events.php
,即mysite.com/alpha/events.php?eventid=10
对应于mysite.com/events.php?eventid=10
但是,我想访问上述路径作为mysite.com/events/10/
代替mysite.com/events.php?eventid=10
。为此,我再次修改了文件,但未能加载dynamic URLs
。 例如,当我将鼠标悬停我的鼠标上的链接,它显示
`mysite.com/events/14`
`mysite.com/events/15`
`mysite.com/events/16`
`mysite.com/events/17`
等这是我想要的东西] 但在点击了[如果我点击悬停显示mysite.com/events/14
链接],它打开一个页面mydomain.com//alpha/events.php/14/14?eventid=
,页面从sql
表中不提取任何内容。
我的.htaccess文件:
# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
RewriteRule ^([A-Za-z0-9\-]+)/([0-9]+)/?$ $1.php?eventid=$3
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/alpha/
# Don't change these line.'
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /alpha/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by/then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ alpha/index.php [L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
@TomWalters:这个问题还张贴由我。这是为了删除'.php'的扩展名,它的确如此。这是为了纠正'sql'提取,因为我面临困难。 – xan
我不认为这个问题与SQL有任何关系 –