I'd like to rewrite URLS like:
http://post.local/web/bundles/silverkixcms/elFinder/elfinder.html?CKEditor=silverkix_cmsbundle_pagetype_content&CKEditorFuncNum=1&langCode=en
to
http://post.local/bundles/silverkixcms/elFinder/elfinder.html?CKEditor=silverkix_cmsbundle_pagetype_content&CKEditorFuncNum=1&langCode=en
Means the part "web/" should be replaced by ""(or remove it), but I have problems to build a rewrite rule for my .htaccess which cover that.
Note: mod_rewrite is on (RewriteEngine on)
RewriteRule ^web/bundles/(.*) bundles/$1 [QSA]
This should work:
RewriteEngine On
RewriteRule ^web/bundles/(.*) /bundles/$1 [R]
The above will remove web/ from the url so
http://post.local/web/bundles/silverkixcms/elFinder/elfinder.html?CKEditor=silverkix_cmsbundle_pagetype_content&CKEditorFuncNum=1&langCode=en
will become
http://post.local/bundles/silverkixcms/elFinder/elfinder.html?CKEditor=silverkix_cmsbundle_pagetype_content&CKEditorFuncNum=1&langCode=en
Related
I'm trying to make my url look good but for some reasons it is not working what could be the problem here
RewriteEngine on
RewriteRule ^view/([^/]*)/([^/]*)$ /view?wall=$1&page=$2 [L]
Above rewrite should resolve like this http://website.com/view/apartment-wallpapers/1247
Alternatively
Preferably I want to make my url to look like this but it's also resulting in
http://lifistudy.com/asus-red-903.html
.htaccess rewrite rule
RewriteEngine on
RewriteRule ^([^-]*)-([^-]*)\.html$ /view?wall=$1&page=$2 [L]
Note: using openlitespeed and all .htaccess rules are working
The issue is in your rewrite rule. You're using ([^/]*) which is incorrect syntax use (.*) and your rewrite rule will work perfectly.
I've been breaking my head on this for quite some time and I don't see the solution.
I want to rewrite a URL with a GET language parameter to a more clean URL.
For instance:
http://www.example.com?lang=en
Needs to be:
http://www.example.com/en
The above works fine with this rewrite rule:
RewriteRule ^(en|nl|fr|de)/?$ /?lang=$1 [L]
But I can't get it to work on URLs like these:
http://www.example.com/contact.php?lang=en
http://www.example.com/about.php?lang=en
That need to be:
http://www.example.com/en/contact.php
http://www.example.com/en/about.php
Anyone have an idea what I'm missing in my rewrite rule to make this work?
You will need an additional rewrite rule for handling /en/about.php:
RewriteEngine On
RewriteRule ^(en|nl|fr|de)/([\w-]+\.php)$ $2?lang=$1 [L,QSA]
RewriteRule ^(en|nl|fr|de)/?$ /?lang=$1 [L,QSA]
I have the following .htaccess file:
# Turn rewrite engine on
RewriteEngine on
# Rewrite url
RewriteRule ^dashboard/(.*)/(.*) /beheer/dashboard.php?m=$1&f=$2
RewriteRule ^dashboard/(.*)/(.*)/(.*) /beheer/dashboard.php?m=$1&f=$2&id=$3 [L]
When I try to go to mydomain.com/beheer/dashboard/test/test I'm redirected to the normal url of mydomain.com/beheer/dashboard.php?m=test&f=test (When I only use the first rewrite else I get 404 error). It might be interesting to know that for some links I also need to pass a third parameter. So for example: mydomain.com/beheer/dashboard.php?m=user&f=delete&id=1. So my question is why isn't this .htaccess file working?
Use end anchor $ in your regex:
# Turn rewrite engine on
RewriteEngine on
# Rewrite url
RewriteRule ^dashboard/([^/]+)/([^/]+)/?$ /beheer/dashboard.php?m=$1&f=$2 [L,QSA]
RewriteRule ^dashboard/([^/]+)/([^/]+)/([^/]+)/?$ /beheer/dashboard.php?m=$1&f=$2&id=$3 [L,QSA]
I need to rewrite only 1 specific URL, to display to visitors specific content: I tried something like, this:
RewriteEngine on
RewriteCond %{REQUEST_URI} example.com/test/2_5/page.html
RewriteRule ^(.*)$ example.com/tt.html [R,L]
I need to rewrite all requests to:
http://example.com/test/2_5/page.html
to
http://example.com/tt.html
how to do this?
thanks,
Redirect /test/2_5/page.html /tt.html
Ok, mod_rewrite
RewriteRule ^/test/2_5/page.html /tt.html [L]
Remove first / if using .htaccess in the site's root folder, not the .conf file. And, typically, the final url should be the full one, with http:// and domain, but this one will work too. If you want to do everything by the rules then
RewriteRule ^/test/2_5/page\.html$ http://example.com/tt.html [L]
I am having some trouble with my ReWrite code. Please note that the .htaccess file is in the subdomain folder (...public_html/subdomain/ )
I am simply trying to rewrite a page request:
http://subdomain.mysite.com/home
http://subdomain.mysite.com/index.php?page=home
My .htaccess file looks like this...
RewriteEngine On
RewriteRule ^/([A-Za-z0-9\-\_])$ /index.php?page=$1
Does anything jump out at you?
Your current rule probably works for urls one character long (after the slash)!
Add a + to signify one or more characters, or a * for zero or more
Try
RewriteEngine On
RewriteRule ^/([A-Za-z0-9\-\_]*)$ /index.php?page=$1
If you want to use the rules in a .htaccess file, you need to strip the contextual per-directory path prefix from the RewriteRule pattern. If the .htaccess file is located in the document root /, you need to strip the leading /.
Additionally you need to quantify the character set. Otherwise it would only describe one character.
So try this rule:
RewriteRule ^([A-Za-z0-9-_]+)$ index.php?page=$1
I think
RewriteRule ^([^/]*)$ /index.php?page=$1 [L]
is ok ;)