简体   繁体   English

重写网址以显示其他网址的内容

[英]Rewrite url to show content from other url

When http://www.placewomen.com/500/400/ is called is it possible to show the contents of http://www.placewomen.com/c/500/400/ , so it makes the c gone? 当调用http://www.placewomen.com/500/400/是否可以显示http://www.placewomen.com/c/500/400/的内容,从而使c语言消失了?

A bit tricky because there is also a check for a empty sub and physically the new url-rewrite doens't exist... 有点棘手,因为还检查了一个空子,实际上新的url重写不存在...

Right now this is my htaccess; 现在,这是我的htaccess;

Options +FollowSymLinks -MultiViews -Indexes

RewriteEngine on

RewriteCond %{HTTP_HOST} ^placewomen.com [NC]    
RewriteRule ^(.*)$ http://www.placewomen.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} \s/+new/index\.php\?var=([^\s&]+) [NC]    
RewriteRule ^ /%1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f    
RewriteCond %{REQUEST_FILENAME} !-d    
RewriteRule ^(.+)$ /new/index.php?var=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} -d    
RewriteCond %{REQUEST_FILENAME}/placeholder.jpg -f    
RewriteRule ^(.*)$ /$1/placeholder.jpg [L]

I'm a frontender myself so perhaps you'll understand this is behind my knowledge... 我本人是一名主持人,所以也许您会理解这是我的知识背后的问题...

您可以使用如下规则隐藏文件夹c

RewriteRule !^c/ /c%{REQUEST_URI} [L,NC]

Try adding this: 尝试添加以下内容:

RewriteCond %{DOCUMENT_ROOT}/c/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/c/$1 -d [OR]
RewriteCond %{DOCUMENT_ROOT}/c/$1 -l
RewriteRule ^(.*)$ /c/$1 [L]

in the middle of your htaccess file: 在您的htaccess文件中间:

Options +FollowSymLinks -MultiViews -Indexes

RewriteEngine on

RewriteCond %{HTTP_HOST} ^placewomen.com [NC]    
RewriteRule ^(.*)$ http://www.placewomen.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} \s/+new/index\.php\?var=([^\s&]+) [NC]    
RewriteRule ^ /%1? [R=301,L]

RewriteCond %{DOCUMENT_ROOT}/c/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/c/$1 -d [OR]
RewriteCond %{DOCUMENT_ROOT}/c/$1 -l
RewriteRule ^(.*)$ /c/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f    
RewriteCond %{REQUEST_FILENAME} !-d    
RewriteRule ^(.+)$ /new/index.php?var=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} -d    
RewriteCond %{REQUEST_FILENAME}/placeholder.jpg -f    
RewriteRule ^(.*)$ /$1/placeholder.jpg [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM