Last weekend I set up a new site at home on Windows (with xampp). Everything works, I get clean URLs (like http://mysite.com/page/about). Today I had to bring the files to my office where I'm using a Mac with MAMP and nothing worked. I change AllowOverride to All in the /Applications/MAMP/conf/apache/httpd.conf file, and enabled LoadModule rewrite_module modules/mod_rewrite.so, with no luck. (Of course, I restarted MAMP)
But nothing happend. All of my webrowsers tell me nothing about the error. Just got the 'localhost:8888/' at the title.
I use these lines in .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([A-Za-z0-9_-]+)(/)?$ index.php?page=$1 [QSA]
RewriteRule ^page/([A-Za-z0-9_-]+)(/)?$ index.php?page=page&uri=$1
RewriteRule ^work/([A-Za-z0-9_-]+)(/)?$ index.php?page=work&uri=$1
</IfModule>
What else I could do to make this working?
Thanks a lot.
This allowed me to serve the file about.php in response to the request path /about:
RewriteRule ^([A-Za-z0-9_-]+)(/)?$ /$1.php [L]
Note that on MAMP you have to put this in .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([A-Za-z0-9_-]+)(/)?$ /$1.php [L]
</IfModule>
Putting that same block in httpd.conf did not work for me on MAMP.
Related
I just moved old site of my client to some test server.
The site is on PyroCMS.
I've changed database settings in aplication/config/database.php and changed base_url in aplication/config/config.php to my test site URL.
Unfortunatly site is giving me 500 error and I don't have any error logs to see what else is to change.
Where I have to do changes to site run?
My .htaccess looks like this:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /wherever/pyro/is
# Keep people out of codeigniter directory and Git/Mercurial data
RedirectMatch 403 ^/(application\/cache|codeigniter|\.git|\.hg).*$
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I use PyroCMS for almost all my clients and the same issue is in the default .htaccess file.
Try to remove:
Options +FollowSymLinks
And try to add:
Options +symlinksifownermatch -Indexes
Options -MultiViews
Many hosting disable +FollowSymLinks for security reason.
Make sure to set 775 permission to:
system/cms/cache
system/cms/logs
addons
uploads
assets
Also make sure to set your env to PYRO_DEVELOPMENT to see all the errors in this debug phase.
I've been struggling with this very rare problem.
I had the following code in my .htaccess file:
Order deny,allow
DirectoryIndex index.php
RewriteEngine on
Rewriterule ^producto/(.+)/(.+) producto.php?id=$1&title=$2
Rewriterule ^pedidos/ pedidos.php
Rewriterule ^peliculas/(.+)/(.+) listado.php?tipo=1&gen=$1&pag=$2
Rewriterule ^musicales/(.+)/(.+) listado.php?tipo=2&gen=$1&pag=$2
Rewriterule ^blueray/(.+)/(.+) listado.php?tipo=4&gen=$1&pag=$2
Rewriterule ^condicionadas/(.+)/(.+) listado.php?tipo=5&gen=$1&pag=$2
Rewriterule ^series/(.+)/(.+) listado.php?tipo=3&gen=$1&pag=$2
And everything worked fine. When I wanted to change the fifth line:
Rewriterule ^pedidos/ pedidos.php
to this:
Rewriterule ^pedidos/(.+) pedidos.php?estado=$1
It did not work. No matter how much I change that line, it won't work.
BUT if I change any other line, the change works.
It's like there's a cached file but I restarted WAMP, I cleaned my computer and browsers with CCleaner, and nothing works.
Can you help me with this?
Try to add that before RewriteEngine on:
Options -MultiViews
i managed to make htaccess working on mac os x but the subcateg rule returns a file not found (404) as i guess does search from the articles folder(?)
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /ks
RewriteRule ^articles/(.*).html$ articles.cfm?subcateg=$1 [NC,L]
RewriteRule ^articles.html$ articles.cfm [NC,L]
The second one seems to be working fine...
Looking at your code, your RewriteBase is /ks/ folder, which means you access it with domain.com/ks/articles/xxxxx.html or domain.com/ks/articles.html and your htaccess is in /ks/ folder.
If that's right, you should disable MultiViews option to avoid your problem.
This code should work on osx, too
Options +SymLinksIfOwnerMatch -MultiViews
RewriteEngine On
RewriteBase /ks/
RewriteRule ^articles/(.+?)\.html$ articles.cfm?subcateg=$1 [NC,L]
RewriteRule ^articles\.html$ articles.cfm [NC,L]
I have a strange problem that only happen on My mac(I do not try in another mac, but did tried on a linux and it works)
this is my .htaccess
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?key=$1
on my index.php I put:
echo $_GET['url'];
it is return a empty array if my url is like this:
localhost/test/index/xpto
but it is return 'index2/xpto' if I put this in the url:
localhost/test/index2/xpto
So the problem is with the string index.
Do you guys know why it do not work on my mac but it does on linux?
I am using standard apache on mac os x lion.
I just change this lines on httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
....
<Directory "/Library/WebServer/Documents">
AllowOverride All
...
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Edited
By working I mean the $_GET['key'] is not empty. And shows the url I put in the browser.
but when I use this url on browser:
http://127.0.0.1/test/index/xpto
my $_GET['key'] is empty
and if I use this url:
http://127.0.0.1/test/anythingbutindex/xpto
the $_GET['key'] have the text:
anythingbutindex/xpto
I did install XAMPP on my mac and this code works fine with index.
So the problem is with the default apache on my MAC.
thanks.
I don't understand how this is working on Linux, or what result that is "working". To me it looks like it's doing what one could expect. I however think your RewriteRule might be a bit wrong. What it will do is that it will pass the entire URI to the index.php file, while I think you just want to parameters after index.php?
If you enter localhost/test/index/xpto, and assuming your DocumentRoot is set to /test the string sent to index.php will be index.php/exto. Same thing apply to index2/exto since the RewriteRule does not care about if you enter index och index2.
You could try this:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^index/(.*)$ index.php?key=$1
If you do want the index parameter in there you could change the RewriteRule to:
RewriteRule ^(index/)(.*)$ index.php?key=$1$2
Hope it helps you forward.
EDIT
After the clarification I understand the question. Some testing later I found that the solution was pretty obvious, but I did not spot it at first. The RewriteRule is slightly off and if I use this it's almost working on my system.
RewriteRule ^(.*)$ /index.php?key=$1 [L]
Note the / before index.php. However this would always redirect to index.php meaning always match the RewriteCond statements. Changing the statement to this however worked at my system.
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
If you have DirectoryIndex set the !-d is kind of redundant since it will always try <path>/index.html or whatever you have configured.
I've had this issue right now and the easiest way to make it work was reinstalling apache via homebrew, so it works identical to the Linux I'm using on a VPS.
It took about two minutes to reinstall, reconfigure the port and I've used virutalhost.sh script to point to the ~/Sites folder
I am trying to transform URLs from index.php to index.html, servicii.php to servicii.html and so on.
I wrote in my .htaccess file, which is in my site root the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
?>
But when I follow "Prima pagina" (Home) or "Servicii" (the only 2 pages created on site) it gives me a 404 error
Also, I have the code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /fetesti/
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
on my local machine, which is XAMPP based. It gives me Object not found 404, and on my Apache log:
file not found [...]/index.html;
I know the rewrite engine is working (I wrote gibberish and it gave me 505 internal server error and made other tests)
What am I doing wrong?
Try just remove [R] permanent redirect, and switch extensions in rule
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php
</IfModule>