Tag Archive permalinks

WSL: Creating links shortcut

การสร้าง hard link หรือ Symbolic link ใน linux จะคล้าย ๆ การทำ shortcut ให้สามารถเข้าไปใช้ไฟล์หรือfolder ได้ง่าย ๆ เหมือน windows shortcut

การใช้ command นี้มีรูปแบบ ln source_file target_file เช่น ต้องการทำ shortcut ให้ /mnt/c/UsersDatas/var/www/prototypes_laravel/www สามารถเรียกใช้ได้จาก /var/www/prototypes_laravel/www ใน linux จะใช้คำสั่ง

sudo ln -s /mnt/c/UsersDatas/var/www/prototypes_laravel/www /var/www/prototypes_laravel/www

ทดสอบโดยใช้ คำสั่งเช่น cd /var/www/prototypes_laravel/www
ls
จะเห็นว่าสิ่งที่อยู่ด้านในจะเหมือนกับที่อยู่ใน /mnt/c/UsersDatas/var/www/prototypes_laravel/www หรือ C:\UsersDatas\var\www\prototypes_laravel\www

ดูเพิ่มเติม

rewrite url ใน iis

โดยปกติ PHP จะใช้ Apache HTTP Server เป็น server ถ้าต้องการให้ URL เรียบร้อยสวยงามก็ใช้ไฟล์ .htaccess แต่ถ้าเราใช้ Internet Information Services (IIS) ก็ต้องไปใช้ไฟล์ ที่คู่กันคือ Web.Config แทน

การที่จะ rewrite url ใน iis จะต้องมีการติดตั้ง URL Rewrite extension เอาไว้ก่อน

ตัวอย่างไฟล์ Web.Config ที่ทำหน้าที่ แปลง ค่าใน url ไปให้ไฟล์ index.php โดยที่จะซ่อนไฟล์ index.php ออกจาก url

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <rewrite>
         <rules>
            <clear />
            <rule name="remove index.php" patternSyntax="Wildcard">
               <match url="*" />
               <conditions>
                  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
               </conditions>
               <action type="Rewrite" url="index.php" />
            </rule>
         </rules>
      </rewrite>
   </system.webServer>
</configuration>

นำไปว่างใน folder ที่ต้องการใช้เช่น folder public ของ laravel เป็นต้น