2012-07-20 202 views
0

如何将网址更改为您想要的名称?例如this site我想将我的网域网址从ahardenjr.com/project.html改为ahardenjr.com/project更改URL名称

我认为这是基本标记,但是当我添加<base href="http://www.ahardenjr/project"/>时,CSS就会中断。有什么建议么?

+0

看[漂亮网址(http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/) – sachleen 2012-07-20 20:30:17

+1

我假设你意思是这样的:http://stackoverflow.com/questions/3825989/htaccess-to-change-url – Palladium 2012-07-20 20:30:38

+4

@nightcracker我不明白PHP是如何进入这个。 – sachleen 2012-07-20 20:31:24

回答

7

看起来你正在试图做一个基本的mod_rewrite。事情是这样的:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^(.*)$ $1.html 
3

一个简单的解决方案是创建一个名为“project”的子目录,然后将“project.html”作为索引文件。我相信应该这样做。

+0

为什么你会使用'project.html'而不是在目录中使用'index.html'? – 2012-07-20 20:33:50

+1

这就是我的意思。对不起,如果我的答案不够清楚。 Nerdysyntax可以将当前为'project.html'的页面重命名为'index.html'。 – JSW189 2012-07-20 20:36:02