typo3 auto redirect realurl news - redirect

I redirect the news with the folling code in htaccess:
RewriteCond %{REQUEST_URI} news-detail\.html
RewriteCond %{QUERY_STRING} L=0 [NC]
RewriteCond %{QUERY_STRING} (tx_news_pi1\[news\]=101|tx_news_pi1%5Bnews%5D=101) [NC]
RewriteRule ^.*$ http://example.net/news/news-detail/8/2016/newstitle? [R=301,L]
The redirect works. Is it possible to use the parameter from QUERY_STRING in RewriteRule? So that every news article is automatically redirected to speaking url. I tried to use some of the parameters from config file but it doesn't work.

You don't get the news title in htacces by the id uid only.
I propose to leave url like they are, use realurl and set a canonical url to the realurl variant

Related

How to redirect index.php pages

How to redirect
/index.php?route=blog/blog to /blog
and
index.php?route=information/contact to /contact
The site is on Opencart 2.3.
I tried with:
RewriteRule ^index.php?route=blog/blog$ /blog [R=301,L]
I've come to the point where pages open in both ways, but don't redirect.
You can't match against query string (anything that goes after ? in URL) in pattern of a RewriteRule . You need to match against %{QUERY_STRING} variable using a RewriteCond directive
RewriteEngine On
RewriteCond %{QUERY_STRING} ^route=[^/]+/(.+)$ [NC]
RewriteRule ^ /%1? [L,R=301]

Why are my forms not working after .htaccess URL rewrite?

I copied the below code from some other posts. It successfully helped me to stripped the .php extension from the URL. However, after implementing this, my forms are no longer working. I have forms that are posting like <form method='post' action='login.php' .... Now it is not sending the data to the location when I submit the form. I realize that if I change the action='login.php' to action='login', the forms will work again. But there are a number of pages that contain forms posting to different locations in my website, and I do not want to change so many of them manually. So I wouold like to know why the data are not posting as expected and how can I solve the problem. Thank you!
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://localhost/domainname/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{REQUEST_FILENAME} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://localhost/domainname/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://localhost/domainname/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
Add this rule on top before other rules to skip all POST requests from rewrite:
RewriteCond %{REQUEST_METHOD} =POST
RewriteRule ^ - [L]
I want to redirect user_login.php to seo friendly url like /user-login with post form data and this worked for me.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/user_login\.php [NC]
RewriteRule ^ user-login [QSA,R=301]
RewriteRule ^user-login$ user_login.php [QSA,L]
In view file
<form action="<?php $siteurl;?>/user-login" method="post" id="user_login">

Lighttpd full URL rewrite to the path

I need to rewrite all possible request to the path of the server
Example: If I enter https://wwww.myhost.com/#hi=random+text+1?stop=now
I need a redirect to:
http://myhost.com/
It is possible with url.rewrite?
Thanks
What are you really trying to achieve? Do you want to hide the urls so that it always shows http://myhost.com. I believe that is not possible if you have more than one page.
Are you trying to redirect everything to for example index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?anything=$1 [QSA,L]
This way for example http://myhost.com/example/ will be handled like the request was http://myhost.com/index.php?anything=example

Redirect URL which contains "option=com_virtuemart"

I want to 301 redirect some URLs which contain "option=com_virtuemart".
I tried with this code:
RewriteCond %{QUERY_STRING} ^option=com_virtuemart
RewriteRule ^(.*)$ http://www.newsite.com/$1 [L,R=301]
But it doesn't work.
The code is working, but the server is disabled htaccess controll..

How do I use .htaccess to force www. while using Zend Framework

I want to force a www. prefix on my website by using a .htaccess 301 redirect. I am currently trying:
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
Which normally works, but I am using Zend Framework which causes all requests to be redirected back to http://www.mysite.com/index.php regardless of the initial request.
For example...
http://mysite.com/blog,
http://mysite.com/contact,
http://mysite.com/blog/this-is-my-article,
Will all be redirected to http://www.mysite.com/index.php
However, if I initially request a specific file, such as...
http://mysite.com/some-file.htm
The redirect works properly, redirecting to http://www.mysite.com/some-file.htm
In first time, don't forget to enable the rewriting ("RewriteEngine on").
The last line is important if you use Zend Framework.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
RewriteRule !\.(pdf|php|js|ico|txt|gif|jpg|png|css|rss|zip|tar\.gz)$ index.php
Now the url...
http://mysite.com/some-file.htm
... redirect to http://www.mysite.com/some-file.htm but use the index.php
Don't forget to ignore sub-domains when re-directing to www.
http://www.theblogaholic.com/2011/01/16/force-www-using-htaccess-except-for-subdomains/