20

The issue here is that your Redirect directive is conflicting with Craft’s index.php-hiding RewriteRule directive. (Redirect is a mod_alias directive and RewriteRule is a mod_rewrite directive. They’re two separate modules that can be used for the same thing, but lead to unexpected consequences when used together.) To fix this, use a RewriteRule directive ...


7

It is not possible yet, but a quick plugin would make this possible. It would just be a controller with a logout action. You'd be able to call the action as a url with: /actions/[PluginHandle]/[ControllerName]/[ActionName] Then you can logout the user the same way Craft does in their controller and edit the redirect as you see fit. Something like this: ...


6

One way you can avoid this is by making a small change to the htaccess rules for removing index.php from Craft URLs. You can remove the query string from RewriteRule (.+) index.php?p=$1 [QSA,L] and replace it with /$1 So the full set of rules to remove index.php would be # Send would-be 404 requests to Craft RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %...


4

Craft has a config setting for this (for dynamic urls) You can set it in your config file like so: 'addTrailingSlashesToUrls' => true If someone links to the url via a non-trailing-slash pattern, it should redirect. If you use an apache rewrite, you can exclude the craft admin by checking the uri pattern RewriteCond %{REQUEST_URI} !(admin)$ ...


4

I found by just adding the code from the following site it will add slashes via a 301 redirect: RewriteCond %{REQUEST_URI} /+[^\.]+$ RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L] Now my .htaccess file looks like the following: <IfModule mod_rewrite.c> RewriteEngine On # 301 redirect with trailing slash RewriteCond %{REQUEST_URI} /+[^\...


4

Based on your comments, I'd recommend creating a new entry type in your section. Create a "Redirect" entry type which only contains a URL link (or an Entry field) so the page knows how to handle the redirect. For any entries that need to be converted to a redirect, simply swap the entry type to use this instead. Then you can simply map that entry type to a ...


4

If you want to "redirect" all parent entries of your structure that have child entries, you could do something like this in your navigation (untested code!): <ul> {% nav page in pages %} <li> {% if page.getChildren()|length %} <a href="{{ page.getChildren().first().url }}">{{ page.title }}</a> ...


3

Sure, something like this should work (untested): <a href="{{ currentUser ? url(craft.config.get('postLoginRedirect')) : siteUrl }}">Home</a> The above should create an absolute URL to whatever's in your postLoginRedirect config setting, relative to your siteUrl. Note that if you want an URL relative to your Control Panel (e.g. "dashboard"), ...


3

Turns out that I was right on the money with my plugin configurations, however earlier I had incorrectly tried to solve the problem using the route below, which was still in place and scuppering my subsequent good work!


2

What happens if you add a ? to the rule: RewriteRule ^blog/category?$ /blog/archive [R=301,L,NE]


2

Instead of using a redirect, what about using the saved URLs directly with your links? Let's say it's a channel with the handle myExternalLinks where you collect the links. The actual URL is entered into a field with the handle myLinkUrl. This is the template code to list the links: {% set links = craft.entries.section('myExternalLinks') %} {% for link ...


2

I fixed it by adding rewrite ^/index.php/(.*) /$1 permanent; to my server block. This will redirect all urls containing index.php and something after it to the contents after index.php. E.g. /index.php/about will be permanently redirected to /about. Google knows that if something is permanently redirected its the same content and will only index the ...


1

The answer here was to redirect to another url using a different template rather than hitting the index template again, which was what was causing the loop.


1

I don't think this is particularly Craft CMS specific problem. Just Apache .htaccess rules in general. I would try to search for and answer of Stack Overflow. I have a strong feeling it's been answered there already. https://stackoverflow.com/questions/7780859/htaccess-rewrite-to-force-trailing-slash-at-the-end


1

OK, no one answered....I have to take another way to do which is to put a piece of code like this into user-profile page {% if not currentUser %} {% redirect '/' %} {% endif %} and take out loginPath setting in config file.


1

It would be much safer and easier to work with if you put all assets folders into domain.com/assets/ as it can cause such conflicts.


1

As your code is running during an event, returning the request to the page has to be done a bit more explicitly than when you are performing similar behavior in a controller. While I'm probably not the best person to explain this in detail, the code below gives one example I was provided in how you can set your route variables and end the request: if ($...


1

Use this redirect tag in the template of your entries. Without any plugin! :) {% redirect entry.myUrlFieldName %}


Only top voted, non community-wiki answers of a minimum length are eligible