So, I set up a website using Nuxt 2 and there is something odd going on with it. I set up my site without using trailing slashes (router options). On refresh the server adds a trailing slash anyway. Normally that wouldn't be a problem, because both pages would just work, but now it just breaks and tells me te page doesn't exist. I have an exact same site with the exact same versions of Nuxt and everything else and that one keeps working on refresh, even with trailing slash.
Setup:
Nuxt 2.18
Static
SRR false
Router options trailingSlash, false
htaccess is now empty again (to test)
I have tried the following things:
Putting trailing slashes on through Nuxt, htaccess and href's.
Set up htaccess to remove trailing slash
Regenerating the site multiple times
None of these solutions seem to work. And it's a pretty big issue, because Google is looking for the sites WITH trailing slash to crawl and index, which now return a soft404, so no indexing whatsoever.
The website is https://expanddigital.nl
I hope someone here found a solution to the problem!
I recommend using the default behavior for Nuxt's trailingSlash setting.
Google doesn't really care about having them both at the same time, and this blog post is from 2010 but I guess it's even more okay nowadays.
There are several possible approaches suggested by the article. Maybe a server configuration could forward the non trailing into some trailing slashes those too, but it's nothing to worry too much about overall.
Related
I recently changed the permalinks of a WP website to contain a trailing slash "/" at the end.
There's a lot of custom made internal linking between thousands of articles.
I'd prefer not to use redirects, but rather to add a slash at the end of all existing internal urls of the entire site.
Is there a way I can do this with an sql query?
I'm not a developer so an exact command will be greatly appreciated!
Thanks!
I would like to change the last part of this URL:
cloud.example.com/apps/files/?dir=/Documents&fileid=1303128
to
cloud.example.com/apps/files/Documents
i.e. remove the "?dir=/" string and the rest from "&fileid=...."
Tried various solutions, but none with a proper result. FWIW, restarted apache after every single change. I would appreciate your help. Rewrite already works for removing index.php from the URL.
I've done everything right. My server has mod_rewrite enabled, my virtualhost path has AllowOverride set to All, and I have the .htaccess file in place with the rewrite rules same as everyone. But I have trouble accessing some pages using their clean url paths. So for 90% of the pages, clean urls work fine. But for that 10%, they don't.
I have checked whether those pages exist -- they do. Checked whether they are accessible using index.php?q=[path] -- and they are. They are only inaccessible through clean url paths.
Can anyone help me with this mystery?
Because you can access your pages through q=path/to/menu/item, then it's clear that it is mod_rewrite that is at fault and not Drupal.
To debug what is going on with your rewrite, either turn on the rewrite log and tail -f it while you request the troubled pages, or alternatively print_r($_GET) at the top of index.php or page.tpl.php to see what is actually being requested.
If you are comfortable posting your potentially sensitive .htaccess here, do so and we can have a look at it for you to see if there are any misconfigurations.
mod_rewrite has a few long-standing bugs that mangle URLs on the way through (do your problem urls have any escape characters?). I don't know if Drupal does this, but in other PHP apps I have had to add code to re-do the rewrite once the correct entrypoint has been reached.
Unfortunately, Drupal can't take its search path in PATH_INFO (as a lot of other apps do), otherwise you could use mod_alias which is much simpler and much more reliable.
So I'm playing with a script that makes it super easy to mirror images off of the web. The script works great (based off of the old imgred.com source, if you've seen that) problem is, it looks a little clunky when using it.
Currently, in order to use the script, you go to a url like:
http://mydomain.com/mirror/imgred.php?Image=http://otherdomain.com/image.jpg
What I'd like to do is to be able to go to:
http://mydomain.com/mirror/http://otherdomain.com/image.jpg
and have it redirect to the former URL, preferably transparent to the user.
I'm reasonably certain that this can be done via .htaccess with a MOD_REWRITE of some kind, but I'm getting frustrated trying to get that to work.
After messing with this myself, I found out that apache collapses any double slash in the URL before the query part into a single slash, and passes the result to mod_rewrite. Maybe that was giving you problems?
This might work for you (.htaccess in the mirror directory):
RewriteEngine On
RewriteBase /mirror
RewriteRule ^http(s?):/(.*) imgred.php?Image=http$1://$2 [L]
Don't know if your script accepts https addresses as well, so I included that just to be sure
I'm managing an established site which is currently in the process of being upgraded (completely replaced anew), but I'm worried that I'll lose all my Google indexing (that is, there will be a lot of pages in Google's index which won't exist in that place any more).
The last time I upgraded a (different) site, someone told me I should have done something so that my SEO isn't adversely affected. The problem is, I can't remember what that something was.
Update for some clarification: Basically I'm looking for some way to map the old paths to the new ones. For example:
User searches for "awesome page"
Google returns mysite.com/old_awesome_page.php, user clicks it.
My site takes them to mysite.com/new_awesome_page.php
And when Google gets around to crawling the site again...
Google crawls my site, refreshing the existing indexes.
Requests old_awesome_page.php
My site tells Google that the page has now moved to new_awesome_page.php.
There won't be a simple 1:1 mapping like that, it'll be more like (old) index.php?page=awesome --> (new) index.php/pages/awesome, so I can't just replace the contents of the existing files with redirects.
I'm using PHP on Apache
301 redirect all your old (gone) pages to the new ones.
Edit:
Here's a link to help. It has a few links to other places too.
You need to put some rewrite rules in an .htaccess file.
You can find lots of good information here. It's for Apache 1.3, but it works for Apache 2, too.
From that article, a sample for redirecting to files that have moved directories:
RewriteEngine on
RewriteRule ^/~(.+) http://newserver/~$1 [R,L]
This reads:
Turn on the rewrite engine.
For anything that starts with /~, followed by one or more of "anything", rewrite it to http://newserver/~ followed by that "anything".
The [L] means that the rewriting should stop after this rule.
There are additional directives that you can use to set a [301] redirect
You could do:
RewriteEngine on
RewriteRule old_page.php new_page.php [L]
But you'd have to have a rule for every page. To avoid this, I'd look at using Regular Expressions, as in the first example.
You can tune Google's view of your site, and probably notify its changes, from within Google Webmaster Tools. I think you should build a sitemap of your current site, and have it verified when the site changes.