开发者

htaccess redirect back to HTTP_REFERER for some specific pages

开发者 https://www.devze.com 2023-02-09 22:53 出处:网络
I want to redirect to http referer page using mod rewrite htaccess. For example, a url request is generated from service.html. I want to redirect back to services.html and if a request is generated f

I want to redirect to http referer page using mod rewrite htaccess.

For example, a url request is generated from service.html. I want to redirect back to services.html and if a request is generated from portfolio.html redirect back to portfolio.html.

Some one may found it silly, but I am in a problem that the same URL is generated within services and portfolio page that belongs to only them not each other's pages.

Example of link generated are:

example.com/design.html example.com/market.html

For referer:

examp开发者_Go百科le.com/service.html

While same for portfolio:

example.com/design.html example.com/market.html

For referer:

exaple.com/portfolio.html

I think it could be achieved by %{HTTP_REFERER} but I don't know how.


This is one way I understand your question:

RewriteCond %{HTTP_REFERER} exaple\.com/(service|portfolio)\.html
RewriteRule /(design|market)\.html http://exaple.com/%1.html [redirect,last]

The other is this:

RewriteCond %{HTTP_REFERER} exaple\.com/service\.html
RewriteRule /design\.html http://exaple.com/service.html [redirect,last]
RewriteCond %{HTTP_REFERER} exaple\.com/portfolio\.html
RewriteRule /market\.html http://exaple.com/portfolio.html [redirect,last]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号