2012-06-24 18:32
浏览 47

重写URL .htaccess,mod_rewrite - “找不到目录”

I'm rewriting urls so my member pages - becomes

If somebody try to reach, the web browser says directory not found. Is there a way to make this directory "real", without adding the folder and an index file? In the .htaccess file?

When I call some scripts firebug will warn me about that the directory doesn't exists as well.

Here's the rewrite rule and entire .htaccess-file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$$1 [L,R=301]

RewriteRule ^user/([^/\.]+)/?$ profile.php?username=$1 [L]

图片转代码服务由CSDN问答提供 功能建议

我正在重写网址,以便我的会员网页 -成为域名。 com / user / John

如果有人试图访问,则Web浏览器会显示找不到目录。 有没有办法使这个目录“真实”,而无需添加文件夹和索引文件? 在.htaccess文件中?


这是 重写规则和整个.htaccess文件:

 &lt; IfModule mod_rewrite.c&gt; 
RewriteEngine On 
RewriteBase / 
RewriteCond%{HTTP_HOST}!^ www \ .domain \。  com [NC] 
RewriteRule ^(。*)$$1 [L,R = 301] 
&lt; / IfModule&gt; 
RewriteRule ^ user /([^ / \。]  +)/?$ profile.php?username = $ 1 [L] 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douxing5598 2012-06-24 19:29

    "What should be rendered if user/ is submitted without a username following it?"

    Doesn't matter really. Back to root I guess.

    Then write a rule specifically for that:

    RewriteRule ^user/?$ / [L]
    解决 无用
    打赏 举报

相关推荐 更多相似问题