RewriteCond doesnt work well - .htaccess

I using Joomla Joomla! 3.4.4 and also XMAP Component 2.3.3
Now i want to Rewrite url when url was :
/index.php?option=com_xmap&view=xml&tmpl=component&id=1
Rewrite
/sitemap.xml
This is my code that i wrote in htacces file,i dont know why doesn't work
RewriteCond %{REQUEST_URI} ^/sitemap.xml
RewriteRule .* /index.php?option=com_xmap&view=xml&tmpl=component&id=1 [L]

You can give this a try.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^sitemap\.xml$ /index.php?option=com_xmap&view=xml&tmpl=component&id=1 [L]

Related

Why doesn't url rewriting work for .html extensions?

I am trying to get
/pages/Settings.html
to appear as
/Settings
by using the RewriteRule
RewriteRule ^([A-Za-z_]+)$ pages/$1.html [NC] # Handle pages
in the .htaccess file. This does not work. However,
/pages/ANYOTHERFILE.php
works by using
RewriteRule ^([A-Za-z_]+)$ pages/$1.php [NC] # Handle pages
to be rewritten into
/ANYOTHERPAGE
Why does the former not work and the latter work? How do I get .html extensions to be rewritten like this?
Add this rules to top of your .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /pages/$1.html [L]

.htaccess in mediawiki not working

I have a wiki up and running at example.com.
when you go to the page the links change in the URL to /index.php/Main_Page
I do not want the parts after / for the main page. Also want the index.php out
I have this currently in my .htaccess
rewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ wiki/index.php?title=$1 [PT,L,QSA]
RewriteRule ^/*$ wiki/index.php [L,QSA]
RewriteRule ^$ wiki/index.php [L,QSA]
and this in my Localsettings.
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
Where is my error? I cannot figure it out ... I followed the mediawiki to the T.
Your three rewrite rules are contradictory and don't match your $wgScriptPath. You probably meant something like:
RewriteRule ^/wiki/(.*)$ w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^/*$ w/index.php [L,QSA]
See https://www.mediawiki.org/wiki/Manual:Short_URL/Apache for more.

How can I do this mod_rewrite?

I want to redirect all http://localhost/webportal/organizations/32 requests to http://localhost/webportal/organizations/32?qt-organization_tabs=tab1#qt-organization_tabs (where 32 is a variable).
How can I do this using mod_rewite?
Update:
I have updated the URLs above, the URLs originally posted were not correct, anyway I tried the following rule and it is not working:
RewriteRule ^/organizations/(.+)$ ^/organizations/$1?qt-organization_tabs=tab1#qt-organization_tabs [L,R]
All the other rules are working properly, here is the relevant part of my htaccess file (Drupal CMS):
RewriteEngine on
RewriteRule "(^|/)\." - [F]
RewriteBase /webportal
RewriteRule ^/organizations/(.+)$ ^/organizations/$1?qt-organization_tabs=tab1#qt-organization_tabs [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
Thanks
Add this in the htaccess file in your document root:
RewriteEngine On
RewriteRule ^/?webportal/organizations/(.+)$ /pepris/webportal/$1?qt-organization_tabs=tab1#qt-organization_tabs [L,R]
You can also use mod_alias:
RedirectMatch ^/?webportal/organizations/(.+)$ /pepris/webportal/$1?qt-organization_tabs=tab1#qt-organization_tabs

?ACT not working anymore after upgrade from ExpressionEngine 2.2.1 to ExpressionEngine 2.5.3

I am completely stuck as to why my EE install after the upgrade to EE 2.5.3 suddenly does not allow for some standard ?ACT eg search (?ACT=2), sending off a contact form or logout (?ACT=10) from the front end.
Actions get redirected to the homepage.
No additional modules installed after upgrade.
my htaccess file includes just a basic redirect
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$1 [L]
Cheers
You should probably have the following in your .htaccess instead - this is likely to be the cause.
RewriteRule (.*) /index.php/$1 [L]
Replace your line :
RewriteRule (.*) index.php?$1 [L]
with the above and it should work.
Usually have these three lines in my .htaccess
RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
RewriteCond %{QUERY_STRING} !^(URL=.*)$ [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

How to change URL? htaccess

What I have
newsy/czytaj/items/odbierz-250zl-na-reklame.html
This is what I would have
newsy/odbierz-250zl-na-reklame.html
How to do this with mod-rewrite? I don't understand RewriteRule.
My .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} (ftp|https?):|/etc/ [NC,OR]
RewriteCond %{QUERY_STRING} (ftp|https?):|/etc/ [NC]
RewriteRule .* - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*\.html$ index.php [L]
RewriteEngine on
RewriteRule ^newsy/([^\./]+)\.html /newsy/czytaj/items/$1.html [L]
This will rewrite anything that starts with newsy and add a /czytaj/items between it and the html file.
In principle you just create a corresponding rewrite rule:
RewriteRule ^newsy/czytaj/items/(.+) /newsy/$1 [L]
It is crucial not to omit [L]flag. Otherwise your rewrite engine may get stuck in an endless loop. Also in the beginning of the .htaccessfile remember to enable mod_rewrite with:
RewriteEngine On
For more help on mod_rewrite, I recommend checking out mod_rewrite-cheatsheet. For an exhaustive URl Rewriting Guide see a corresponding page from Apache 2.0 Documentation.

Resources