跟随超链接时,Mod_rewrite不起作用

时间:2016-09-19 12:41:09

标签: jquery apache .htaccess mod-rewrite

我正在建立一个像这样工作的投资组合(link here):

  • 首页(index.php)通过AJAX POST
  • 加载项目
  • 这些项目包含指向自己的/idea/example-idea页面的超链接(从/idea.php?url=example-idea重写)

问题是,即使/idea.php?url=example-idea工作正常,这些超链接也会将我带到非重写页面(/idea/example-idea)。

实施例: 单击Pedal-Powered Music Machine项会将我带到/idea.php?url=music-machine-r48,即使超链接是/idea/music-machine-r48,这会导致从地址栏读取的JQuery出现问题。

这是我的.htaccess文件:

RewriteEngine on

RewriteRule ^idea/([A-Za-z0-9-]+)/?$ idea.php?url=$1 [NC,L,NE] 

RewriteCond %{HTTP_HOST} !^owenpickering.com$ [NC]  
RewriteRule .? http://owenpickering.com%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule .? /404.php [L]

有什么想法吗?提前谢谢。

1 个答案:

答案 0 :(得分:1)

试试这个,

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^idea/([A-Za-z0-9-]+)/?$ idea.php?url=$1 [NC,L,NE] 

#this is causing the redirecting
#RewriteCond %{HTTP_HOST} !^owenpickering.com$ [NC]  
#RewriteRule .? http://owenpickering.com%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule .? /404.php [L]
相关问题