I have test project folder called "prj". In that, I have one file called test.php.I want something like
http://localhost/prj/test.php?t=123
should be rewritten like
http://localhost/prj/test.php
any help will be appreciated
Create a .htaccess file with:
RewriteEngine on
RewriteRule ^prj\/test.php$ prj/test.php?t=123 [NC]
Edit
If your htaccess file is located in the prj folder:
RewriteEngine on
RewriteRule ^test.php$ test.php?t=123 [NC]
Related
i have try a few solution from any source, but still cannot remove index.php if my project in other folder like : http://localhost/project/my_codeigniter, all .htaaccess and configuration work fine if my project in http://localhost/my_codeigniter.
hope you can help me, thanks!
You can create a .htaccess file on your project root folder. File content like this;
RewriteEngine on
RewriteCond $1 !^(index\.php|assets)
RewriteRule ^(.*)$ /your-project/index.php/$1 [L]
I have this htaccess file in the 'public_html' folder:
RewriteEngine On
RewriteRule ^asset/(.*)$ asset.php?code=$1 [NC]
Essentially, the rewrite condition should work as follows. When a user clicks on a link ../asset/XXX, the asset.php file generates a new webpage containing details of the XXX asset.
The lookup is not working as I think the htaccess file cannot find the 'asset.php' file.
The asset.php file is located in
'public_html/wp-content/themes/theme1/asset.php'
How can I modify the htaccess file to lookup this file?
Have you tried:
RewriteRule ^asset/(.*)$ wp-content/themes/theme1/asset.php?code=$1 [NC]
The rewrite is from your directory where the htaccess file is located. So add the path to the destination file.
RewriteEngine On
RewriteRule ^asset/(.*)$ wp-content/themes/theme1/asset.php?code=$1 [NC]
Perhaps you can set the RewriteBase to /. Sometimes that fixes some problems.
Not 100% sure how but I know its simple .htaccess but I have no idea what to do.
Basically I want it to load a index.php file no matter what url they go to in the folder containing the index.php for example:
http://website.com/folder/thisisntafile.php will load: index.php in the folder named folder. This will happen for whatever /folder/file.php is loaded.
Thanks!
Try this :
RewriteEngine on
#Rewrite "folder/file"
#don't rewrite "folder/index.php"
Rewritecond %{REQUEST_URI} !/index.php$
RewriteCond %{REQUEST_URI} ^/([^/]+)/[^.]+(\.php|html)?$
RewriteRule ^ /%1/index.php [NC,L]
This rewrites
http://example.com/foo/bar.php
to
http://example.com/foo/index.php
I am nto able to rewrite URL as I need.
I have the following document structure:
1) root - root folder where .htaccess should be placed in
2) root/folder1 - subfolder
3) root/folder1/public - this is folder where index.php is
Thus I need that mydomain.com would open index.php inside "public" folder. And all other requests would go via it.
I tried this, but it doesn't work (p.s. I am writing rewrite rules first time). I put it inside root folder.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$
RewriteCond %{REQUEST_URI} !^/$1
RewriteRule !^folder1/public /folder1/public%{REQUEST_URI} [L,NC]
I have a similar .htaccess like yours, so I edited a bit mine. Does this worked for you?
The condiftion for .css|.js is needed otherwise it will send as plain/text instead of normal css/js
RewriteEngine on
RewriteCond %{REQUEST_URI} !\.(css|js)$
RewriteRule ^([^?]*)$ root/folder1/public/index.php [NC,L,QSA]
How to write .htaccess rewriterule for the below URL.
I am new to htaccess.
http://velloredentists.com/search.php?s=VASAN+DENTAL+CLINIC&c=Bagayam )
to
http://velloredentists.com/search/VASAN+DENTAL+CLINIC/Bagayam
Please help me to solve this.
This worked on my apache server :
RewriteEngine On
#Redirect "/search.php?s=foo&c=bar to
#/search/foo/bar
RewriteCond %{THE_REQUEST} /search.php\?s=([^&]+)&c=([^\s]+) [NC]
#Rewrite "/search/foo/bar" to
#"/search.php?s=foo&c=bar"
RewriteRule ^ /search/%1/%2? [NC,R,L]
RewriteRule ^search/([^/]+)/([^/]+)/?$ /search.php?s=$1&c=$2 [QSA,L,NC]
1 - First you need to check if the file .htaccess exists in the root of your website.
2 - If the file .htaccess exists, download it from your site, add the lines below to the end of the file, and upload the modified file back to your site. Please make a copy of the original file .htaccess. So if anything goes wrong, you may restore the original file.
3 - If the file .htaccess does not exist, create a new file .htaccess and add the lines below to it. Then upload it to the root of your website. You may delete it if anything goes wrong.
Add the following lines to .htaccess:
RewriteEngine On
RewriteRule ^search/([^/]*)/([^/]*)\.html$ /search.php?s=$1&c=$2 [L]