Alright, I'm just trying to setup a simple rewrite rule for a site.
First off, in httpd.conf I have
LoadModule rewrite_module modules/mod_rewrite.so
Then in a seperate file I have this alias setup
Alias /vworker/ "f:/vWorker/"
<Directory "f:/vWorker/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Alright now, so the directory of the site is
f:/vWorker/urlmask
In there I have an .htaccess file that says this
RewriteEngine on
RewriteRule ^redirect/([0-9]+)/?$ index.php?redirect=$1 [L]
Now, what I want, is if I go to the url http://localhost/vworker/urlmask/redirect/3161513 it will actually call http://localhost/vworker/urlmask/index.php?redirect?3161513
From my point of view everything seems to be set up right, and if I put gibberish in my .htaccess file I get a server error, so I know it's reading it.
What I end up with is a page that says "Not Found. The requested URL /vworker/urlmask/redirect/94173336828903446 was not found on this server."
Any ideas what I'm doing wrong?
In general, whenever you've got an Alias, you're going to need a RewriteBase to make things work as expected.
In your case, you should have
RewriteBase /vworker/urlmask/
in the same .htaccess as your rules.
Related
There are some PHP files on an external drive which is mapped to the Z: drive on a Windows 10 machine. This code is in the httpd-vhosts.conf Apache file:
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
</VirtualHost>
The task at hand is to allow .htaccess overrides for a file path within the path shown above. In the httpd.conf file the rewrite module is enabled. That line looks like this: LoadModule rewrite_module modules/mod_rewrite.so. I tried adding this code to the httpd.conf file:
<Directory "Z:/files/xampp/htdocs/miscellaneous/WebServiceExamples">
AllowOverride All
</Directory>
The Apache web server was stopped and restarted after making these changes. The code in .htaccess looks like this:
<IfModule mod_rewrite.c>
# turn rewrite engine on
Options +FollowSymlinks
RewriteEngine on
# map neat URL to internal URL
RewriteRule ^mobile/list/$ RestController.php?view=all [nc,qsa]
RewriteRule ^mobile/show/([0-9]+)/$ RestController.php?view=single&id=$1 [nc,qsa]
</IfModule>
However, when a URL that should be handled by the rewrite rule in the .htaccess file is entered in the Chrome address bar the result is an Object not found! Error 404. Where did I go astray?
EDIT:
Another thing I tried was putting httpd.conf back to its original state, then modifying httpd-vhosts.conf as follows:
<VirtualHost *:8080>
DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
Options Indexes
Require all granted
</Directory>
<Directory "Z:/files/xampp/htdocs/miscellaneous/WebServiceExamples">
AllowOverride All
</Directory>
</VirtualHost>
After stopping and restarting the Apache web server, the result is still the same as before:
Object not found! Error 404.
Figured this out. The configuration files were left in the state as described in the Edit section in the original post. The Troubleshooting section in this link was a helpful guide for determining that the configuration files were set up correctly.
This was entered as the URL in Chrome's address bar: http://localhost:8080/miscellaneous/WebServiceExamples/SimpleRestfulWebService/mobile/list. Notice there is no trailing forward slash. The rewrite rule was in .htaccess was written in such a way that made a trailing forward slash mandatory. When the rewrite rule lines were modified to make the trailing slash optional, then it worked fine. Here are the modified rewrite rules:
RewriteRule ^mobile/list/?$ RestController.php?view=all [nc,qsa]
RewriteRule ^mobile/show/([0-9]+)/?$ RestController.php?view=single&id=$1 [nc,qsa]
Trying to fix this .htaccess, so it can work on a SSL apache server. Before it was hosted on another Linux server (http://) and was working without problems, but when uploading the files to another Linux server with apache and SSL (https://), it stopped working. The main function is to hide the .php extension...
HereĀ“s what I was using:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
Thanks for your help!
So, .htaccess files may not be allowed, and by default on many systems they are not allowed. To see if .htaccess is allowed, make this your .htaccess:
BREAK IT!
That should be the only contents in your .htaccess. Attempt to load any page on your website, and if .htaccess usage is enabled, you would see "Internal Server Error" or possibly some other error, but you would not see your actual page.
If you do see the error, that's actually good and means .htaccess usage is enabled. If you don't see the error, it's likely that you will have to find your Apache .conf file and inside look for the line(s):
AllowOverride None
Change that to:
AllowOverride All
If after doing that you still can't use .htaccess, then there may be other apache related files that have "AllowOverride None". On that comes to mind is your virtual host file, and on my system that is located at /etc/apache2/sites-available/.
If you still have problems, check this out:
https://docs.bolt.cm/3.3/howto/making-sure-htaccess-works
Solution is for the issue, need to change in apache2.conf file after that it will works,
Change this file /etc/apache2/apache2.conf
update it same
OLD:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
New Updated Code:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I had a similar problem. Apache 2.4.23 with .htaccess error 404 set up.
Using it with HTTP works fine; access it with HTTPS didn't work.
I seted AllowOverride All in the http.conf and error 404 wors well.
First of all, I simply wanted to use another folder as the default htdocs directory.
In order to do so, I added these lines into my httpd.conf:
AliasMatch ^/php/(.+)$ F:/PHP/$1
<Directory "F:/PHP/*">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
The problem I experienced was that the URL rewriting I had set up for the former htdocs wasn't working properly. To do the rewriting, I had used this RewriteRule directive in my .htaccess file:
RewriteRule ^((?:(user|admin|debug)/)?[a-z_/]+)/(?:([0-9]+)/)?$ index.php?page=$1&auth=$2&id=$3
... which was located in "F:/PHP/lif-web-interface/" on my drive.
The URL I want to display is the following:
http://127.0.0.1/php/lif-web-interface/factionlist/
If it had performed correctly, I would have seen a rewritten URL with collected GET parameters on its end. When I had tried to add the [R] parameter, the output I got changed into the following:
http://127.0.0.1/F:/PHP/lif-web-interface/index.php?page=factionlist&auth=&id=
... which, surprisingly, was the thing I wanted to see. But yet, I didn't want to redirect onto that page, I just wanted to replace the URL.
Do you have suggestions what I should do?
I assume you've put those rules in the htaccess file in the F:/PHP folder. If so, then try adding a base:
RewriteBase /php/
RewriteRule ^((?:(user|admin|debug)/)?[a-z_/]+)/(?:([0-9]+)/)?$ index.php?page=$1&auth=$2&id=$3
If the rules are in the document root, then you need to include the path:
RewriteRule ^php/((?:(user|admin|debug)/)?[a-z_/]+)/(?:([0-9]+)/)?$ /php/index.php?page=$1&auth=$2&id=$3
I am facing a very common issue here hoping someone have the same experience could help me.
The issue is quite normal. I could find plenty issue posts and solutions by search google.
For example:
http://wordpress.org/support/topic/wordpress-permalink-404-issue
But the weird thing is after I delete # from
#LoadModule rewrite_module modules/mod_rewrite.so
and also did this part:
I opened up the httpd.conf file and found:
<Directory />
Options FollowSymLinks
AllowOverride none
Order deny,allow
Deny from all
</Directory>
and changed the AllowOverride none to AllowOverride all.
Now it's looking like this:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
but it's still not working.
I'm using WAMP for my localhost and the website works well when I change permalink setting back to default (with post ID).
Here is the .htaccess code I'm using.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dev/mysite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/mysite/index.php [L]
</IfModule>
# END WordPress
Did I miss something? Really need your help! Thanks in advance.
I Got Answer. It's easy only.
1) Go to WAMP logo in right-bottom of Task-bar of Windows.
2) Click left button
3) then Apache -> Apache Modules
4) Tic(select) the rewrite_module
5) that's all.
For More
1) Go to WAMP logo in right-bottom of Task-bar of Windows.
2) Click left button
3) then Apache -> Apache Modules
4) Tic(select) the rewrite_module
5) that's all.
THIS WORKS, THANKS A MILLION.
I spent hours trying to solve this problem, f* ridiculous!
I'm just learning to use wordpress and got completely stuck with a simple thing like adding a page, complete waste of time. Almost decided to use joomla....
I am facing a very odd issue with Snow Leopard and Apache's mod_rewrite. I have set this up on Linux servers countless times, and it always worked. Being quite new to OS X, I'm quite puzzled.
This is my current configuration file as found in /etc/httpd/users/username.conf:
DocumentRoot "/Users/username/Sites/"
<Directory "/Users/username/Sites/">
Options Indexes MultiViews +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Now my problem is that whenever I try to access a rewritten url I get a 403 Forbidden page. I have tried to see if there was any information in the log, but nothing is coming up, so I'm left here wondering. To be sure, my permissions seem to be fine (I have tried 755 and 775).
For reference, this is my .htaccess file:
RewriteEngine On
RewriteRule ^hello$ home.php [NC,L]
RewriteRule ^oops$ sorry.html [NC,L]
Just to make double sure I have set AllowOverride All in the main httpd.conf file (under Directory /).
Any advice is greatly welcome.
Thanks for your time :)
EDIT: I have just noticed that if I use a VirtualHost everything works as expected, so I wonder how my RewriteRules are being read by Apache...