Why can't the two rewrite rules work together and how to fix?
I'm trying to get wwww.mydomain.com/wordpress to wwww.mydomain.com/pages/wordpress.php
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^([a-z]+)(.*)$ /pages/$1.php [QSA,L]
Thanks,
You want the new rule before any of the wordpress rules:
RewriteEngine On
RewriteBase /
RewriteRule ^([a-z]+)(.*)$ /pages/$1.php [QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
The wordpress rule routes everything to index.php, including whatever it was you're trying to match.
Related
I have conflict RewriteRule .htaccess.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
RewriteRule ^unsubscribe.php$/template/site.org/newsletter/unsubscribe.php
RewriteRule ^(unsubscribe)/?$ /$1.php [L,NC]
This
RewriteRule . /index.php [L]
Conflict with
RewriteRule ^unsubscribe.php$/template/site.org/newsletter/unsubscribe.php
RewriteRule ^(unsubscribe)/?$ /$1.php [L,NC]
Please help me to fix it.
Your unsubscribe rule needs a space between pattern and target but more importantly you need to place these rules before catch-all index.php rule. You can also combine 2 last rules into one:
RewriteEngine on
RewriteBase /
RewriteRule ^unsubscribe(?:\.php)?$ /template/site.org/newsletter/unsubscribe.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
I moved from apache 2.2 to 2.4 but this code RewriteRule ^(pl)($|/) - [L] in .htaccess is not working now. I´v tried almost everything, but I am still not able to make it work.
Can somebody help? Please
htaccess in root:
RewriteEngine On
RewriteRule ^(pl)($|/) - [L]
RewriteCond %{HTTP_HOST} ^([a-z.]+)?myweb\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.myweb.com%{REQUEST_URI} [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
htaccess in PL dir:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This should be htaccess in /pl/ dir:
RewriteEngine On
RewriteBase /pl/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
I'm trying to get my htaccess file to use this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
to rewrite this url:
http://cheesecakebb.org/index.php?action=vn
Try this instead:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index/([^/]+)/?$ index.php?action=$1 [QSA,L]
When someone clicks example.com/index/something, it will redirect (invisibly to the user) to index.php?action=something
I've got old urls and want to remove the /index.php/ via .htaccess:
So old url is:
www.mysite.com/index.php/onesite.html
rewrite in .htaccess into
www.mysite.com/onesite.html
How can I do that?
Thx for your help
Adding the following code to your htaccess will allow this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index.php/(.*)$ www.mysite.com/$1 [R=302,L]
Changing 302 to 301 when you are sure the redirect is working
Try this one:
RewriteRule ^index.php/(.*?)$ http://%{HTTP_HOST}/$1 [R=301,L]
Just add this in your .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
If you site is in subfolder then
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule>
You can use these 2 rules in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^index\.php(/.*)?$ $1 [L,R=301,NC,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ /index.php/$1 [L]
I have the following entries handled as fixed files using .htaccess (for example)
RewriteEngine On
RewriteRule ^redir$ redir_base64.php
RewriteRule ^confirm$ confirm.php
RewriteRule ^migrate$ migrate.php
RewriteRule ^import_conn$ import_conn.php
RewriteRule ^callback_ot$ callback_ot.php
RewriteRule ^callback_yh$ callback_yh.php
RewriteRule ^callback_gp$ callback_gp.php
RewriteRule ^callback_lk$ callback_lk.php
RewriteRule ^results/map$ index.php
RewriteRule ^results$ index.php
RewriteRule ^robots\.txt$ robots.php
RewriteRule ^sitemap\.xml$ sitemap.php
RewriteRule ^removeml$ removeml.php
RewriteRule ^rss$ rss_gen.php
RewriteRule ^cpt\.jpg$ c/captcha/captcha.php
RewriteRule ^cptfrm\.jpg$ c/captcha/captcha.php?width=120&height=60&characters=4
RewriteRule ^cptfrm160\.jpg$ c/captcha/captcha.php?width=100&height=60&characters=3
RewriteRule ^login/lk$ login_conn.php?op=lk
RewriteRule ^t$ c/thumb/phpThumb.php
RewriteRule ^spce$ spce.php
RewriteRule ^orplkd$ order_publisher.php
RewriteRule ^ord_ren$ order_reactivate.php
RewriteRule ^logout$ logout.php
This entry works fine! But I need to access /000/000 and I see that an conflict with lines indicates below.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\d\w\-\.]+)/([\d]+)$ index.php [QSA,L]
RewriteRule ^([\d\w\-\.]+)$ index.php [QSA,L]
I try to access to my site using that lines but I cannot to recognize only the last lines because use ALL access on the site.
I hope so understand my help.
Thanks!
You need to repeat the 2 conditions. Rewrite conditions only apply to the immediately following condition.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\d\w\-\.]+)/([\d]+)$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\d\w\-\.]+)$ index.php [QSA,L]