fbpx Slash - Meysmahdavi

Tag Archive :Slash

Remove / from the end of WordPress links using .htaccess file

In this WordPress tutorial, we want to provide you with a simple and short, but practical way to remove slash (/) from all links on your site.

Of course, all sites are so expanded that all of them may have links with an / at the end. But today we will show you how you can get rid of them all using a short code snippet.

Be extremely careful when using this code. In some content management systems (cms) such as WordPress, especially after installing SEO plugins, the slash / sign is always at the bottom of the site pages link and it is not necessary to delete it, but it is better to do so.

Therefore, by redirecting the address with slash to the address without slash, we prevent such problems. To do this, just copy the following code into the .htaccess file in WordPress.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^\.localhost$ [NC]
RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

In the above code, the formats gif | jpg | png | jpeg | css | js are excluded from removing the slash from the bottom of the link. You can add more formats if needed.

حذف / از انتهای لینک های وردپرس با استفاده از فایل htaccess

در این نوشته از آموزش وردپرس میخواهیم به شما روشی ساده و کوتاه، اما کاربردی برای حذف اسلش (/) از تمامی لینک های سایتتان ارائه کنیم.

قطعا تمامی سایت ها به قدری گسترش و توسعه پیدا میکنند که در تمامی آنها ممکن است لینک هایی وجود داشته باشد که در انتهای آنها یک / اضافه، موجود باشد. اما امروز به شما نشان خواهیم داد که چگونه میتوانید با استفاده از یک قطعه کد کوتاه، تمامی انها را از بین ببرید.

در استفاده از این کد نهایت دقت را داشته باشید. در برخی سیستم های مدیریت محتوا (cms) نظیر وردپرس، به ویژه پس از نصب افزونه های سئو ساز، همواره علامت اسلش / در انتهای لینک صفحات سایت قرار دارد و الزامی به حذف آن نیست، اما بهتر است که این کار انجام شود.

از این رو با ریدایرکت کردن آدرس با اسلش بر روی آدرس بدون اسلش، از بروز چنین مشکلاتی پیشگیری می کنیم. برای انجام این کار، کافیست کد زیر را در فایل .htaccess موجود در وردپرس کپی کنید.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^\.localhost$ [NC]
RewriteRule ^(.+[^/])/$ http://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

در کد فوق، فرمت های gif|jpg|png|jpeg|css|js از حذف اسلش از انتهای لینک استثناء قائل شده است. در صورت نیاز می توانید فرمت های بیشتر را اضافه نمایید.