i am using post affiliate pro and they have a script to turn a web page at www.example.com into a banner for affiliates, the htaccess uses a php script to load the affiliates info into the website/banner.
i am trying to convert the htaccess to nginx conf file. i have tried the converters at winginx and anilcetin
they work but it changes the url from www.example to pap.example.
on an Apache server with .htaccess the url is maintained www.example. this is what i am trying to duplicate on the nginx server.
here is the htaccess file.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/(.*) http://pap.example.com/scripts/page.php?a_aid=$1&a_bid=7c4ec277&a_file=$2 [L,P,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+) http://pap.example.com/scripts/page.php?a_aid=$1&a_bid=7c4ec277&a_redir=Y [L,P,QSA]
thanks for any help
Sean
Related
I have a custom PHP CMS website.
https://example.com/
I have been able to remove the .php extension for https://example.com/archives for example.
But when it comes to:
https://example.com/single-article.php?getid=1425
I have tried EVERYTHING the code just won't change in the .htaccess.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^single-article/([0-9]+)/([09-9a-zA-Z_0]+) single-article.php?getid=$1
Any ideas?
Need help with litespeed web server .htaccess rules.
http://example.com/temp/home.php is existing URL, but now what we need to rewrite is mentioned below:
http://example.com/temp.php?redirect=home.php
And our Existing .htaccess code is also given below.
RewriteEngine on<br/>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
But I don't know the issue, this rewrite still not working and shows 404 error because temp/home.php does not exist.
These rules are working perfectly with Apache server, but not working with Litespeed
For reference:
https://htaccess.madewithlove.be?share=d15d3bca-6974-5682-902a-823c1a63e2b7
Thanks in advance.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^temp/(.*)$ temp.php?redirect=$1 [QSA,L]
The above code will serve the content of temp.php?redirect=home.php.
As a test I created temp.php in the root directory of a domain, with the content:
<?php
var_dump($_GET);
The result when accessing /temp/home.php is:
array(1) {
["redirect"]=>
string(8) "home.php"
}
This is tested on LiteSpeed Web Server 5.3.4 and 5.3.5.
I am working on a site where I have many short URLs which is redirected to a bigger version of URL. The idea is that the short URLs are distributed offline and users generally remembers them and types in the browser address bar. As example:
http://www.example.com/abc should redirect to http://www.example.com/higher_education/companion/politics/abc.html
Also there are some external links as well. like: http://www.example.com/google will redirect user to https://www.google.com
EDIT -
There is another scenario where http://www.example.com/elementary/def.html will be redirected to http://www.example.com/elementary/xyz.html
However, we now want to achieve this with RewriteMap. The code that we've written for that is as below:
<IfModule rewrite_module>
RewriteEngine on
RewriteMap custommap txt:/var/www/vhosts/example.com/httpdocs/map.txt
#RewriteCond %{REQUEST_URI} !^/index.php$
RewriteRule "^(.*)$" "${custommap:$0}" [R,L,NC]
</IfModule>
The map.txt contains:
abc http://www.example.com/higher_education/companion/politics/abc.html
google https://www.google.com
The problem is .htaccss file contains also some RewriteRule.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)\.html$ /index.php?sid=$1&ssid=$2 [L,NC,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /index.php?sid=$1 [L,NC,QSA]
So any request comes with .html will be served by index.php as standard CMS feature. However, now the code goes into redirect loop.
If someone shares some light in order to mitigate this issue then that would be great. The Apache version is 2.2 so I can't use any IF-ELSE in that.
Regards,
Aneek
You should put some restrictions on the rule serving URLs from RewriteMap:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${custommap:$0} !^$
RewriteRule ^[^.]+$ ${custommap:$0} [R=301,L,NE]
This will ensure only non-files and non-directories with no DOT in URI will be handled by custommap.
More importantly it will also check existence of a mapping in custommap before redirecting.
Make sure you clear your browser cache before testing this change.
I have a custom php file at the following url
http://www.paradox4a.com/wp-content/themes/whitetheme/custompage.php
I want the user to visit the above link using a virtual url like that
http://www.paradox4a.com/activate/
Is that possible using the .htaccess rewrite_mod ?
In the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^activate/$ /wp-content/themes/whitetheme/custompage.php [L]
I am trying to redirect a bunch of old blog article URLs using the .htaccess file:
RedirectMatch ^/index\.php/global/article/(.*)$ http://www.mywebsite.com/blog/article/$1
This doesn't really work, however, because my CMS seems to get confused by the index.php bit and keeps adding ?symphony-page= to all the URLs.
It's probably this part that is responsible:
### FRONTEND REWRITE - Will ignore files and folders
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING} [L]
Can anybody help?
Please try the following (comments included to explain):
RewriteEngine On
# First, redirect the old URIs to the new ones via a 301 redirect.
# This will allow the CMS to take over using the rules that follow.
RewriteRule ^index.php/global/article/(.+)$ /blog/article/$1 [L,R=301]
# Frontend Rewrites - for the CMS
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING} [L]
Try this:
#-- Input URL >> http://www.mywebsite.com/index.php/global/article/abc
### FRONTEND REWRITE - Will ignore files and folders
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}
RewriteCond %{REQUEST_URI} ^/index\.php/global/article/(.*)$
RewriteRule ^.*$ blog/article/%1 [R=301, L]
#--Output URL >> http://www.mywebsite.com/blog/article/abc
I've tested the above with this htaccess.madewithlove and it seems like it will work just fine, hopefully it will work for you too
Screenshot: