I have the following within my htaccess page:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*?)$
index.php?page=$1
</IfModule>
but this does not work and gives me the Internal error (500).
but if I comment out the last two lines the page loads ok not errors but fails to d what I want it to.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
#RewriteRule (.*?)$
#index.php?page=$1
</IfModule>
Any ideas what this could be??
Mac Snow Leopard.
My directory is within DocumentRoot "/Library/WebServer/Documents" and I do not use the normal http://localhost/~User/ but http://localhost/?? etc
Thanks
UPDATE:
I have come back to this as sidelined on other things for ages. So please find my new details below, with these details i get the following error still:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, you#example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
my url:
localhost/exp/index.php
My htaccess:
RewriteEngine On
RewriteRule (.*?)/(.*?)/(.*?)$
exp/index.php?page=$1&action=$2&id=$3
No wif I comment out all except the 'RewriteEngine On'
RewriteEngine On
#RewriteRule (.*?)/(.*?)/(.*?)$
#exp/index.php?page=$1&action=$2&id=$3
I get the 403 forbidden message. I fi comment them all out the page loads.
my /etc/apache2/httpd.conf file details are below:
<Directory />
Options Indexes MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/Library/WebServer/Documents/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I use this as my localhost and not my user one localhost/~User/
So to the life of me do not knwo whats going on.
# Turn on URL rewriting
RewriteEngine On
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php?page=URL
RewriteRule .* index.php?page=$0 [PT]
the answer came from here:
Answer to my question here
RewriteEngine On
RewriteRule ^(.*?)/(.*?)/(.*?)$ index.php?page=$1&action=$2&id=$3
seems to be the break and it needing to be on one line?
Related
I have migrated one of my client's sites to Linode. Now the homepage is working and the rest of the pages shows "NOT Found" and "The requested URL /apk-download/ was not found on this server."
Apache/2.4.25 (Debian) Server at www.frpbypass.us Port 80
URL: [http://www.frpbypass.us][1]
I have tried to change:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Also, added the WordPress default .httaccess.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
After making the changes, I have restarted the Apache web server as well as Server reboot.
Any idea of how to fix?
Thanks in advance.
Simply go to setting -> permalink and change your default permalink setting twice.
It will change the default htaccess and your site will start working.
Finally, I am able to fix the issue. If you're experiencing the same issue then first just saving the Permalink should fix the issue. If not then try .htaccess method and finally looking for apache2.conf file.
In my case, I made all the changes as above but enabling the apache2 rewrite mod fixed my issue.
Use this command:
sudo a2enmod rewrite
Hope this helps anyone who faces the same issue. It took hours of research to finally fix the issue.
The objective is to input an url like
https://www.mywebsite/expert/188/name-of-the-expert
and return it to the server in the form
expert.php?exp=188
Like if the user typed in https://www.mywebsite/expert.php?exp=188
WHAT DOES NOT WORK:
simple rules like RewriteRule ^expert-([0-9]*)$ expert.php?exp=$1 [L,NC,QSA]
WHAT WORK
I have the following rewrite_rule that works only when I physically create the folder expert/ in my tree, i.e. /www/expert/
# FRIENDLY URL FOR EXPERTS PROFILE
Rewriterule ^(.*)expert\/([0-9]*)(\/[a-z0-9\-\']*)?\/?$ expert.php?exp=$2 [L,NC,QSA]
Also, for this rule to work, I had to put the <base href="/"> in the page expert.php to avoid errors with all my linked resources:
Failed to load resource: the server responded with a status of 404 ()
The server is APACHE on a shared web hosting platform named OVH.
The full code of the issue:
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
# FRIENDLY URL FOR EXPERTS PROFILE
Rewriterule ^(.*)expert\/([0-9]*)(\/[a-z0-9\-\']*)?\/?$ expert.php?exp=$2 [L,NC,QSA]
</IfModule>
Have it like this with MultiViews turned off:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
# FRIENDLY URL FOR EXPERTS PROFILE
Rewriterule ^/?expert/(\d+)/?$ expert.php?exp=$1 [L,NC,QSA]
Option MultiViews (see http://httpd.apache.org/docs/2.4/content-negotiation.html) is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So if /file is the URL then Apache will serve /file.html.
I changed from using rewrite rules to using Apaches FallbackResource after reading https://www.adayinthelifeof.nl/2012/01/21/apaches-fallbackresource-your-new-htaccess-command/. It's more of a 'if page not found, then run this page instead'
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
FallbackResource /root.php
</Directory>
The only thing I have found is that if the URL is for page that does exist - then it serves that instead of your base new base page 'root.php' in my case.
My laravel application is working well on localhost, but now having moved my application to a production server, it is no longer recognizing any $_GET variables passed through the URL. My production server is set up to allow multiple laravel installations, and I am handling the rewriting with a vhost.conf file and an .htaccess file located in the laravel root.
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /international-experts/index.php/?$1 [L]
</IfModule>
vhost.conf
Alias /international-experts "/srv/http/international-experts/public"
<Directory /srv/http/international-experts>
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo Indexes
Order allow,deny
Allow from all
</Directory>
What I have done to test it is with print_r($_GET) on multiple pages. Nothing. Reading up on the problem, it sounds like MultiViews might be part of the problem. I know I'm not the only one handling multiple laravel installations on the same server... has anyone else had to tackle this problem?
Thanks
In the rewrite rule
RewriteRule ^(.*)$ /international-experts/index.php/?$1 [L]
you create a new query string with ?$1 and the default behaviour in this case is to throw away the old query string. You need to use the flag QSA, which you can remember as "query string append"
RewriteRule ^(.*)$ /international-experts/index.php/?$1 [L,QSA]
If not enough to solve your problem, it is surely a part of it.
i ran into a similar problem of $_GET[] empty. mostly because of a server issue somewhere and i had to generate my own $GET using $_SERVER['HTTP_REFERER'].
//url='http://example.com/?search=john&location=london';
$get=array();
$query=mb_split("&",parse_url($_SERVER['HTTP_REFERER'],PHP_URL_QUERY));
if(!empty($query)) foreach ($query as $qr){
$vars=mb_split('=',$qr);
$get[$vars[0]]=$vars[1];
}
var_dump($get['search']);
I have a Wordpress-installation on a server with two domains pointing to it. The plan is to set up a SEO-friendly redirect including 301-redirection and 404 error-handling. I am using 3 files: Apache virtua-host, .htaccess and php-skript (error page for http status code404
Vhost (Apache)
<VirtualHost xx.xxx.xxx.xx:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /path/to/mydomain-on-filesystem
<Directory /path/to/mydomain-on-filesystem>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.mydomain-to-be-redirected\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain-with-content.com/$1 [R=301,L]
ErrorDocument 404 /404.php
.htaccess and 404.php are located /path/to/mydomain-on-filesystem.
I have trouble making the RewriteRule (301 redirect) and ErrorDocument (404 error handling) work together. As soon as the RewriteRule is in place I get "301 move permanently" when I enter any URL. It completely ignores http status code 404. Unfortunately that causes Google (as far as I heard) and other search engines to decrease the Page Ranking (e.g. duplicate content).
What am I missing here? Any help is greatly appreciated.
Looking forward to read from you guys :-)
Thanks a lot!
S.D.
The rewrite rules:
RewriteCond %{HTTP_HOST} ^www\.mydomain-to-be-redirected\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain-with-content.com/$1 [R=301,L]
redirects everything from www.mydomain-to-be-redirected.com to www.mydomain-with-content.com. Anything below that will not get used.
In this case, www.mydomain-with-content.com will return the 404 if the page is not there, which seems like what you would want to happen.
I've look through the tutorials in web, and below is what I had done to test if mod_rewrite work.
First: Uncomment the mod_rewrite.so(#httpd.conf)
Second: Allowoverride -> Allowoverride all(#httpd.conf)
Third:(#.htaccess)
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^dra/?$ draft.php [NC,L]
</IfModule>
finally: if my code work the url should be rewritten to localhost/xampp/test/dra/ according to (editted from) url-rewriting for beginner
Final result: mod_rewrite not working, as you can see in the picture. Anything that I had left out?
In httpd-xammp.conf
transform
Allowoverride AuthConfig to Allowoverride All
I think it will help you
You want:
RewriteRule ^xampp/test/dra/?$ /xampp/test/draft.php [NC,L]
Or simply:
RewriteRule dra/?$ /xampp/test/draft.php [NC,L]
The RewriteRule takes from what comes after domain/ in your case it would what comes after http://127.0.0.1/ or http://localhost/.
Also this rule is not to change your draft.php, this rule you have is to allow you to access:
http://localhost/xampp/test/dra/
And have your draft.php serve it without showing it.
I was following this tutorial, and the problem for me was the suggested line:
RewriteEngine on RewriteRule .* good.html
did not work. It has to be on two separate lines:
RewriteEngine on
RewriteRule .* good.html