简体   繁体   中英

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?

A bit tricky because there is also a check for a empty sub and physically the new url-rewrite doens't exist...

Right now this is my 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:

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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