My problem is that I can't figure out why my htaccess doesn't work.
When I check FTP path it is /var/www/html/folder/subfolder/
Since I am running WP site and I need that subfolder to be accessible, so I have this:
RewriteEngine On
RewriteBase /folder/subfolder/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ./index.php
I tried with adding html and of course removing folder but nothing is working.
Can anybody help me?
Thank you.
If you have httpd 2.2.16 or above, you should use FallbackResource instead of all those rewrite rules:
Put a .htaccess inside the folder you wish to have redirects for
Add FallbackResource /index.php
Have cake.
Related
I have downloaded a web template and when i try to run that in my localhost the folder doesn't show up.that folder contains a .htaccess file.When i remove that file i can see the folder but when i open that it gives some errors.
This is the .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^$ index.php [L]
RewriteRule ^([a-zA-Z0-9]+)?$ user-profile.php?user_username=$1 [NC,L]
this is the first time i'm working with a .htaccess file...
Any help is appreciated.
Maybe problem in the index.php file PHP code? Rewrite rules looks fine.
Show us the Apache error log and a rewrite log, without that hard to say what is wrong.
It looks like the RewriteCond directive is in the wrong place...? I would have thought it should apply to the 2nd RewriteRule, not the first:
RewriteEngine On
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9]+)?$ user-profile.php?user_username=$1 [NC,L]
RewriteCond directives apply to the single RewriteRule that follows. That 2nd ruleset basically says that if the requested file does not exist then internally rewrite the request to the user-profile.php page passing the request (which is assumed to be a username) to the user_username parameter.
I need help regarding URL redirection
I want to set a affiliate url like localhost/mysite/bussname/proname, when a viewer will see this link and click it it will redirect to
localhost/mysite/mypage.php?bussinessname=bussname&productname=proname
I already use this code
Redirect 301 localhost/mysite/bussname/pagname localhost/mysite/mypage.php?bussinessname=bussname&productname=proname
It causes internal server URL.
So, what will be the possible code in htaccess. Please help me, thanks in previous.
Try something like:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mysite/([^/]+)/([^/]+)$ /mysite/mypage.php?bussinessname=$1&productname=$2 [L,QSA]
You'll need to make sure you have AllowOverride Fileinfo or AllowOverride All in the server config for your document root, and that mod_rewrite is loaded. Then the rules need to go in an htaccess file in your document root.
If you have relative links in your page's content, you may need to change them to absolute URLs or add this to the page's header:
<base href="/mysite/" />
if you want the users to see the new url, you should use redirecting:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^mysite/([^/]+)/([^/]+)$ /mysite/mypage.php?bussinessname=$1&productname=$2 [R=301,L]
otherwise, if you do not want them to see the new url, you should use rewriting:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^mysite/([^/]+)/([^/]+)$ /mysite/mypage.php?bussinessname=$1&productname=$2 [L]
Both codes should be placed inside the .htaccess file in the root directory of your webhost, which should start with the line RewriteEngine ON
I'm trying to rewrite my URL from this:
http://www.example.com/admin/index.php?id=title
to:
http://www.example.com/admin/title
I'm using this code in my htaccess:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /admin/index.php?id=$1 [L]
But then when I try out rewritten URL's i get a 404 error from my server. What is the mistake I'm making? The .htaccess is in a subfolder called admin and the rewrite rule should only work for that folder.
This .htaccess should be placed inside the folder admin that must be inside your root folder:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /admin/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ index.php?id=$1 [L]
The 2 conditions make sure we are not redirecting an existent file or folder and rule tells we want to extract anything not a / and use as the ID.
The RewriteBase tell us your parent folder is admin and as such we work from there and onwards.
My website structure is as follows:
.htaccess
index.html
internal
.htaccess
test.html
api.php
I have setup a subdomain in GoDaddy such that internal.ledworld-me.com maps to ledworld-me.com/internal and the following works fine:
Requesting internal.ledworld-me.com/test.html serves the test.html file correctly.
Now I need the following:
If internal.ledworld-me.com/nonexistent/file is requested, then the URL should be rewritten as ledworld-me.com/internal/api.php?__route__=/nonexistent/file.
What do I put in my .htaccess file in order to achieve this? And which .htaccess file should I put the code in, the one under WebRoot or the one under internal?
Please note that GoDaddy is taking care of the rewriting from internal.ledworld-me.com to ledworld-me.com/internal. All I need my .htaccess file to do is the second part of the rewrite, namely, /nonexistent/file should be rewritten as api.php?__route__=/nonexistent/file.
It's really hard to explain this question and I've tried my best, please ask for clarification if needed. Thank you!
Put this code in your /internal/.htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ api.php?__route__=/$1 [L,QSA]
The following text in my internal/.htaccess file seems to do the trick:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://ledworld-me.com/internal/api.php?__route__=/$1
I'm still testing all the scenarios and will confirm that everything is working once I'm done all the tests.
I am using Apache mod_rewrite on Xampp on my local machine but the code doesnt seem to work.
Please look at the code below and assist me. I'm a beginner with this.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^m3/([a-zA-Z0-9-]+)$/?profile=com_frontpage&url=$1 [L,QSA]
What I want is the URL below:
http://localhost/m3/?profile=com_frontpage&url=nero
to be rewritten as
http://localhost/m3/nero
Please help me achieve this.
Thanx
Thanks for your quick responses
I have implemented the revised code given but once I try to enter the new URL I keep getting a 404 error.
I am using Xampp on a Windows OS so renaming the file to .htaccess is being rejected and I am not sure using 'htaccess.txt' is working.
What could be the issue?
Thanx
Change your RewriteBase.
RewriteEngine on
RewriteBase /m3/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-]+)$ index.php?profile=com_frontpage&url=$1 [L,QSA]
EDIT: Fixed syntax.
Make sure you have this option set in your document root directory in Apache's httpd.conf file:
AllowOverride All
You want this if your .htaccess file is located in the site root (in the htdocs folder):
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^m3/([a-zA-Z0-9-]+)$ m3/index.php?profile=com_frontpage&url=$1 [L,QSA]
Also, you need to save your file as .htaccess. Just "Save As..." from whatever editor you're using and save the file as .htaccess. The only place that you can't do this from is within Windows Explorer, but that's just Explorer being stupid; you definitely can save the file with the correct name from a program (even Notepad).
Or, if you prefer, you can do it from command line:
cd C:\path\to\xampp\htdocs\
rename htaccess.txt .htaccess