Adding trailing slash to sitemap - sitemap

Would it be possible to add a trailing slash on the sitemap?
For example my current sitemap :
<url>
<loc>
https://www.website.com.au/shop/category/laser-therapy/capillus272-laser-cap
</loc>
<lastmod>2018-09-24T10:12:15+09:30</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
I want to add a trailing slash on this part https://www.website.com.au/shop/category/laser-therapy/capillus272-laser-cap
Is this possible?
Thanks!

That would certainly be possible. in yor template that generates the xml file, do something like:
<loc>
{page_url}/
</loc>

Related

How to create image paths which contain spaces?

In Sphinx, I am trying to include images from a subdirectory.
While this works for paths without spaces such as
.. image:: imagepath/image.png
I am not successful for paths with spaces.
What I have tried is:
.. image:: imagepath with space/image.png
.. image:: `imagepath with space/image.png`
.. image::`imagepath with space/image.png`
What am I missing? Many thanks in advance.
It is not possible to include image paths which contain spaces. You will have to rename those image files.
I don't know if there is a simpler way, but at least, it is possible to replace a space with backslash space:
.. figure:: imagepath\ with\ space/image.png

How to convert query string to url names

My url is ..../blogs?id=1&title=news
Now i need to covert this to
..../blogs/1/news
in .htaccess.
Please how to convert this. help me.
Use these lines:
RewriteEngine on
RewriteRule ^blogs/(.+)/(.+)$ /blogs.php?id=$1&title=$2 [R,L,QSA]

Open file one directory below

I can't really explain or title this one so I'll use an example.
On my website I want /img/image.jpg/1.jpg to open image.jpg when opened but keep that URL. Basically I want that whatever is entered after image.jpg/ doens't matter and it would always open image.jpg. Could it be done with .htaccess setting or would I need to do something more advanced?
Yes, this can be done using .htaccess :
RewriteEngine On
RewriteRule ^img/image.jpg/.*$ image.jpg
EDIT :
To make image.jpg a variable too, you have to use brackets like this :
# This rule will match every URL img/nameofimage.jpg/randomcaracters and will redirect to nameofimage.jpg
RewriteRule ^img/([a-zA-Z0-9]+\.jpg)/.*$ $1

Help with mod_rewrite

I have my site under the structure: www.somesite.com/index.php?page=p_section_page.php
I want my site to display something like: www.somesite.com/section/page OR just www.somesite.com/page/
Tried to write rules in the .htaccess file like so:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule PAGE index.php?page=p_section_page.php
It works fine if i try www.somesite.com/page/ but the images, css files and js, try to access the www.somesite.com/page/css/ or www.somesite.com/images/ directories which clearly do not exist.
Any help here? Thanks!
My educated guess is that you are using relative paths. If you change the URL of the HTML document you change the effective path of pictures, scripts and other resources that are loaded via relative paths. It's the same as when you move the file to another directory.
I find it easier to call resources with absolute paths. You are using PHP so you have two options: hard-code the leading slash or use PHP to set it:
<img src="/images/picture.jpg" ... >
<img src="<?=$_SERVER['DOCUMENT_ROOT']?>images/picture.jpg" ... >

.htaccess redirect to page with anchor link

I'm trying to set up a .htaccess file to redirect pages from one domain to another. Works in 99% of cases, the RewriteRules that aren't working are like the one below - if the outbound URL has an #anchor tag, the # symbol is converted into the characters %23 in the browser and then the page does not load at the anchor. Any idea on how to interpret the # tag correctly?
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
Options -MultiViews
Options +FollowSymlinks
RewriteEngine on
RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1#illustration-110
If I cut and paste "http://example.org/s-b-g/b-1#illustration-110" into my browser directly, it loads just fine, but using the RewriteRule, the URL that loads is "http://example.org/s-b-g/b-1%23illustration-110" ... The new site is a drupal site, if that helps any. Thanks.
Try it with the NE flag:
RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1#illustration-110 [NE]
because .htaccess usually interprets # as a comment it kind of defeats proper interpretation ..
so instead of using the # in your rewrite rule actually use the %23 code instead.
so your rewrite becomes:
RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1%23illustration-110 [NE]
more accurately is becomes:
RewriteRule bg/row_b1_i_pn1.php http://example.org/s-b-g/b-1/%23illustration-110 [NE]

Resources