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]
Related
My main domain is smile.ws
I have installed yourls in smile.ws/yourls.
As a result, all my shortened urls are smile.ws/yourls/link instead of smile.ws/link
I followed the wiki instructions but that didn’t help.
I looked around and found a plugin called "Swap Short Url" which is supposed to help in these situations. It has slightly different .htaccess recommendation. I followed the instructions correctly and it works, because now the urls are smile.ws/link. But when you click on them, you get a 404 error.
How can I fix this? Thanks!
PS I know this is not a programming question. However, Stackoverflow has a tag for YoURLS that has 55 questions.
This to me sounds like it is related to the web servers .htaccess file but I can't be certain unless you can give us an example. I have a YOURLS site that work as you are describing without using a plugin. This really comes down to how the web server is configured and the YOURLS settings. Here is a sample of my .htaccess file.
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS
In your config file this line needs to look like this.
define( 'YOURLS_SITE', 'http://smile.ws' );
If this doesn't work it might be due to your web server not having the correct permissions set or the rewrite module not enabled assuming you are using apache.
Did anyone check the root .htaccess?
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /YOURLS/yourls-loader.php [L]
</IfModule>
# END YOURLS
This line needs to set the subdirectory /your dir here/
RewriteRule ^.*$ /YOURLS/yourls-loader.php [L]
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 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
Can somebody tell me how to get mod_rewrite to rename this:
our-work-section.php?id=3&title=something
to
our-work-section/something/3
Right now my .htaccess is in directory C:\workspace\www\brown, My vhost is setup for http://workspace/, So I did a RewriteBase below. I currently Have:
RewriteEngine On
RewriteBase /www/brown/
RewriteRule ^/our-work-section/?$ our-work-section.php?id=$1 [NC,L]
My error log isn't saying anything, and the page doesn't do anything. I've tried toggling slashes / here and there.
Try this one
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(our-work-section)/?$ /our-work-section.php?id=$1 [L]
EDIT
This one will work. I tested it
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(our-work-section)/([^/\.]+)/?$ /our-work-section.php?id=$1 [L]
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.