Rewrite .htaccess resulting in 404 - php

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.

Related

.htaccess simple rewrite rule not working in subdirectory

I'm working on a subdirectory, and want to rewrite ugly file-urls into prettier URLs.
Like:
domain.com/myfolder/myreport.php --> domain.com/myfolder/MyReport/
Here's what I have:
RewriteEngine On
RewriteRule ^test/?$ index.php [NC,L]
Taken from here
However, it's not working. I've tested every combination of regex I could imagine, nothing worked.
Are there any other potential problems? Is it possible that all rules are ignored/overwritten by a rule in the root directory or something?
The .htaccess IS being used, if I add "test", I get a 500 Error.
Can you just try the following,
RewriteEngine on
RewriteBase /myfolder/
RewriteRule ^(.*)$ /myfolder/index.php?/$1 [L]

How to rewrite specific URL using htaccess

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]

Search and replace part of URL via apache htaccess RewriteRule

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

Rewrite URL using htaccess php

I want to rewrite the url in my project.
For example:
http://www.example.com/dashboard/test/ to http://dashboard.example.com/index.php
Also I want to do it for:
http://www.example.com/dashboard/test2/ to http://dashboard.example.com/index.php
Can anyone tell me the idea to rewrite the url?
First you create a .htaccess file in your root.
Than, just put the redirect commands in it.
How to compose a .htaccess and how to create rewrite rules is explained here: http://net.tutsplus.com/tutorials/other/the-ultimate-guide-to-htaccess-files/
You will need something like:
RewriteRule ^(.*)$ http://dashboard.example.com/$1 [L,QSA]
try this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^test.*$ http://dashboard.example.com/index.php [R=301,L]

Mod_rewrite rule not passing PHP variables

I am trying to rewrite the URL (using mod_rewrite) as requested by the user:
http://example.com/question/1/
To load this URL from the server:
http://www.example.com/question.php?qid=1
I am currently using the rewrite rule:
RewriteEngine On
RewriteRule ^question/([^/\.]+)/?$ question.php?qid=$1 [L]
But this does not work. I have tried other things in the .htaccess (such as redirects) and this work, so I know that the .htaccess is being processed.
Thank you.
According to your example, your rewrite rule should be something like:
RewriteRule ^question/(\d+)/?$ /question.php?qid=$1 [L]

Categories