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]
Related
Here is the website I'm specifically talking about: http://anomet.com.
The home page loads fine, but navigating to another page doesn't, unless it's prefixed with index.php. For example: http://anomet.com/index.php/lighting works, but http://anomet.com/lighting doesn't. The website was created using Laravel 5.4.15. The website is hosted on Bell's server, and when I called them, they said mod_rewrites should be enabled. I have proper permissions set on my storage folder as well (755), since I've read that not having proper permissions on the Laravel folder can cause this problem. Here is my .htaccess file below:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
AddHandler phpCGI .xml .php
Action phpCGI /cgi-bin/php5.6fcgi
# for php5 and securewebexchange
<IfDefine SSL>
AddHandler phpCGI .xml .php
Action phpCGI https://secure9.securewebexchange.com/anomet.com/cgi-bin/php5.6fcgi
</IfDefine>
Is Bell wrong in saying that mod_rewrites is enabled? The tech support person didn't sound confident on the phone, and they didn't actually check the configuration files (i.e. httpd.conf or apache.conf) to see if it had anything like AllowOverride All or Require all granted inside of it.
Lastly, I have the exact same files uploaded to a Namecheap server (https://kdev.solutions/) and everything works on there, which further leads me to believe that the problem is with Bell's server configuration.
I have sniffed through quite a few postings about mod_rewrite this turned out more complex than I was expecting.
What I am trying to do is the following.
I have 10 cities with events, and each city should have their own "directory" such as:
site.com/toronto/
site.com/chicago/
The events could have up to 3 sub levels such as
site.com/toronto/musiccamp/sub18
site.com/chicago/bootcamp
And I need these URLs mapped to the page
site.com/camps/index.php?city=toronto&type=musiccamp&ages=sub18
site.com/camps/index.php?city=chicago&type=bootcamp
Other directories, such as
site.com/about - site.com/help etc
should NOT be rewritten.
This has to be within an .htaccess file.
So far I got this going (in godaddy servers)
#Fix Rewrite
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test/index.php?option1=$1 [L]
However I am unable to pass the options to index.php... they are always null...
In the end, this is what worked best in my case
#Fix Rewrite
Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test/index.php?option1=%{REQUEST_URI}
That way any path that does not exist will get rewriten to the /test/index.php file and can be handled from there.
Passing the REQUEST_URI allows me to build N level deep and have the index.php file parse it out.
Hope this helps someone.
In my root folder I have installed wordpress and there is also my submenu.php that can not be loaded with ajax if I use rules for /%postname%/ (in default )
So this is what WP gave me
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
What do I need to add so that calling
$('#submenu').load('submenu.php?cat=4');
works again?
This is not the way you should be performing AJAX within WordPress.
I suggest you read up on Using AJAX within WordPress from the codex.
I am not really good with htaccess, but this
RewriteRule !^media/ index.php [L]
Will redirect everything except media/* to index, so something like this should work
RewriteRule !^yourscript.php index.php [L]
Note: I agree with Jason there, using it without htaccess is better.
In ExpressionEngine, what’s the best way to mod_rewrite a directory to a subdomain, while keeping index.php out of the picture?
For example:
http://www.domain.com/index.php/group/template -> group.domain.com/template
I’ve seen variations that take ANY group and rewrite them to subdomains, but I only need one.
I’ve been tasked with porting over a subsite from a different server (that was also running EE). Normally, I’d just redirect group.domain.com to domain.com/group (index.php removal was already working), but that’s been deemed an unacceptable solution. And of course, this is time-sensitive.
I’ve been diving into Google and the EE docs/wiki for going on twelve hours and I’m starting to go cross-eyed. Can anyone give me a hand?
Thanks in advance.
Here's how I would craft your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(group|group/.*)$
RewriteRule ^(.*)$ http://group.domain.com/template/$1 [L]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
This example uses the "File and Directory Check" Method of removing index.php from the URL and uses a RewriteCond Directive to instruct Apache to handle the requests for the "group" directory and all its sub-directories differently.
Any links to domain.com/group/template will be redirected to group.domain.com/template/.
If you care about letting crawlers know your content has moved and want to make the transition as seamless as possible, you can add a 301 Redirect to your RewriteRule:
RewriteCond %{REQUEST_URI} ^/(group|group/.*)$
RewriteRule ^(.*)$ http://group.domain.com/template/$1 [R=301,L]
This will ensure that users and search engines are directed to the correct page.
i have a simple rewrite
RewriteRule ^.*$ addnew/$0
however i get the
Request exceeded the limit of 10 internal redirects due to probable configuration error.
I am trying to rewrite
www.mysite.com/anycharacter
into
www.mysite.com/addnew/anycharacter
Try the folllowing solution, it works for me.I hope this will work for you too.
BEFORE DOING ANYTHING - BACKUP YOUR DB!
Now, go into wordpress > settings > permalinks
Set it to one of the pretty permalink settings like //year/month/'
Open a text editor on your PC/Mac and open the .htaccess file you downloaded from your
webserver
Find this piece of code
# BEGIN Wordpress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Replace it with this piece of code, courtesy of Scott Yang:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L,QSA]
</IfModule>
Upload this code into the main domain root directory on your server and you're done.
Everything should work
As RC already said, .* will also match addnew/. And since the L flag causes a reinjection of the rewritten rule, you will get an infinite recursion.
So adjust the rule so it doesn’t match your addnew/:
RewriteRule !^addnew/ addnew%{REQUEST_URI}
.*matches addnew/. Try with:
RewriteRule ^[^/]*$ addnew/$0